42 lines
889 B
Bash
42 lines
889 B
Bash
#!/bin/bash
|
|
|
|
closed=
|
|
mode=80 # 80 || 443 <=> http || https
|
|
|
|
if [[ "$(command -v nginx)" == "" ]];then
|
|
|
|
echo "[INFO] Installing Nginx..."
|
|
|
|
apt update && apt -y upgrade && apt -y autoremove
|
|
apt install -y nginx
|
|
|
|
# chmod +x docker.entrypoint.sh
|
|
|
|
fi
|
|
|
|
echo "[INFO] Settings Nginx..."
|
|
|
|
/etc/init.d/nginx restart
|
|
[[ -f /etc/nginx/sites-enabled/default ]] &&
|
|
run rm /etc/nginx/sites-enabled/default
|
|
for type in available enabled;do
|
|
[[ ! -f /etc/nginx/sites-$type/nginx.$mode.conf ]] &&
|
|
[[ -f /Projects/nginx.$mode.conf ]] &&
|
|
ln -s /Projects/nginx.$mode.conf /etc/nginx/sites-$type/nginx.$mode.conf
|
|
done
|
|
|
|
echo "[ OK ] Nginx installet and set fully."
|
|
|
|
echo "[INFO] Restarting Nginx..."
|
|
|
|
/etc/init.d/nginx restart
|
|
|
|
trap "closed=1" INT TERM EXIT
|
|
while [[ "$closed" != "1" ]];do
|
|
wait || wait
|
|
sleep 1
|
|
done
|
|
|
|
echo "[INFO] Stopping Nginx..."
|
|
|
|
/etc/init.d/nginx stop |