addet php and nginx option
This commit is contained in:
parent
72d02eb3c0
commit
2545e917d5
1 changed files with 50 additions and 11 deletions
51
.zshrc
51
.zshrc
|
@ -232,19 +232,58 @@ _alias(){
|
||||||
alias dl="docker compose log -f"
|
alias dl="docker compose log -f"
|
||||||
alias dc="docker compose"
|
alias dc="docker compose"
|
||||||
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
|
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
|
||||||
drweb() {
|
drweb() {
|
||||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
drweb_help() {
|
||||||
echo "Usage: drweb [directory] [port]"
|
echo "Usage: drweb <server_type> [directory] [port]"
|
||||||
|
echo " server_type: Type of server to use (nginx or php)"
|
||||||
echo " directory: Directory to serve (default: current directory)"
|
echo " directory: Directory to serve (default: current directory)"
|
||||||
echo " port: Port to use (default: 8080)"
|
echo " port: Port to use (default: 8080)"
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||||
|
drweb_help
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local dir="${1:-./}"
|
local server_type="$1"
|
||||||
local port="${2:-8080}"
|
local dir="${2:-./}"
|
||||||
|
local port="${3:-8080}"
|
||||||
|
|
||||||
|
if [[ ! -d "$dir" ]]; then
|
||||||
|
echo "Error: Directory $dir does not exist"
|
||||||
|
drweb_help
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$server_type" in
|
||||||
|
nginx)
|
||||||
|
if [[ -f "$dir/index.html" || -f "$dir/index.php" ]]; then
|
||||||
docker run -p "$port:80" -v "$dir:/usr/share/nginx/html:ro" nginx:alpine
|
docker run -p "$port:80" -v "$dir:/usr/share/nginx/html:ro" nginx:alpine
|
||||||
}
|
echo "Nginx is serving $dir on port $port"
|
||||||
|
else
|
||||||
|
echo "Error: No index.html or index.php found in $dir"
|
||||||
|
drweb_help
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
php)
|
||||||
|
if [[ -f "$dir/index.php" || -f "$dir/index.html" ]]; then
|
||||||
|
docker run -p "$port:80" -v "$dir:/var/www/html" php:7.4-apache
|
||||||
|
echo "PHP Apache is serving $dir on port $port"
|
||||||
|
else
|
||||||
|
echo "Error: No index.php or index.html found in $dir"
|
||||||
|
drweb_help
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unsupported server type '$server_type'"
|
||||||
|
drweb_help
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
|
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue