linux - systemd support
This commit is contained in:
@@ -40,13 +40,14 @@ echo "[*] Run jobs"
|
||||
do_and_check_cmd "/opt/bunkerized-nginx/entrypoint/jobs.sh"
|
||||
|
||||
# Reload nginx if it's running
|
||||
if [ -f "/tmp/nginx.pid" ] ; then
|
||||
status="$(systemctl status nginx 2>&1)"
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "[*] Reload nginx"
|
||||
AS_ROOT="yes" do_and_check_cmd nginx -s reload
|
||||
AS_ROOT="yes" do_and_check_cmd systemctl reload nginx
|
||||
# Otherwise start it
|
||||
else
|
||||
echo "[*] Start nginx"
|
||||
AS_ROOT="yes" do_and_check_cmd nginx -g 'daemon on; user nginx;'
|
||||
AS_ROOT="yes" do_and_check_cmd systemctl start nginx
|
||||
fi
|
||||
|
||||
# Done
|
||||
|
||||
@@ -360,6 +360,15 @@ if [ "$NGINX_VERSION" != "1.20.1" ] ; then
|
||||
echo "/!\\ Warning : we recommend you to use nginx v1.20.1, you should uninstall your nginx version and run this script again ! /!\\"
|
||||
fi
|
||||
|
||||
# Stop nginx on Linux
|
||||
if [ "$OS" != "alpine" ] ; then
|
||||
echo "[*] Stop nginx service"
|
||||
systemctl status nginx > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
do_and_check_cmd systemctl stop nginx
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo "[*] Update packet list"
|
||||
if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then
|
||||
@@ -724,13 +733,19 @@ do_and_check_cmd cp /tmp/bunkerized-nginx/misc/variables.env /opt/bunkerized-ngi
|
||||
if [ "$OS" != "alpine" ] ; then
|
||||
echo "[*] Copy UI"
|
||||
do_and_check_cmd cp -r /tmp/bunkerized-nginx/ui /opt/bunkerized-nginx
|
||||
do_and_check_cmd cp /tmp/bunkerized-nginx/ui/bunkerized-nginx-ui.service /etc/systemd/system
|
||||
do_and_check_cmd cp /tmp/bunkerized-nginx/ui/bunkerized-nginx-ui.service /lib/systemd/system
|
||||
fi
|
||||
|
||||
# Copy bunkerized-nginx
|
||||
echo "[*] Copy bunkerized-nginx"
|
||||
do_and_check_cmd cp /tmp/bunkerized-nginx/helpers/bunkerized-nginx /usr/local/bin
|
||||
|
||||
# Replace old nginx.service file
|
||||
if [ "$OS" != "alpine" ] ; then
|
||||
do_and_check_cmd mv /lib/systemd/system/nginx.service /lib/systemd/system/nginx.service.bak
|
||||
do_and_check_cmd cp /tmp/bunkerized-nginx/misc/nginx.service /lib/systemd/system/
|
||||
fi
|
||||
|
||||
# Create nginx user
|
||||
if [ "$(grep "nginx:" /etc/passwd)" = "" ] ; then
|
||||
echo "[*] Add nginx user"
|
||||
@@ -811,10 +826,13 @@ do_and_check_cmd chmod u+rx /opt
|
||||
do_and_check_cmd chown -R nginx:nginx /etc/nginx
|
||||
do_and_check_cmd find /etc/nginx -type f -exec chmod 0774 {} \;
|
||||
do_and_check_cmd find /etc/nginx -type d -exec chmod 0775 {} \;
|
||||
# Set permissions for /etc/systemd/system/bunkerized-nginx-ui.service
|
||||
# Set permissions for systemd files and reload config
|
||||
if [ "$OS" != "alpine" ] ; then
|
||||
do_and_check_cmd chown root:root /etc/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd chmod 744 /etc/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd chown root:root /lib/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd chmod 744 /lib/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd chown root:root /lib/systemd/system/nginx.service
|
||||
do_and_check_cmd chmod 744 /lib/systemd/system/nginx.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
fi
|
||||
|
||||
# Prepare log files and folders
|
||||
|
||||
@@ -30,14 +30,23 @@ elif [ "$(grep Ubuntu /etc/os-release)" != "" ] ; then
|
||||
OS="ubuntu"
|
||||
elif [ "$(grep CentOS /etc/os-release)" != "" ] ; then
|
||||
OS="centos"
|
||||
elif [ "$(grep Alpine /etc/os-release)" != "" ] ; then
|
||||
OS="alpine"
|
||||
fi
|
||||
if [ "$OS" = "" ] ; then
|
||||
echo "[!] Unsupported Operating System"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop nginx
|
||||
systemctl status nginx > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "[*] Stop nginx service"
|
||||
do_and_check_cmd systemctl stop nginx
|
||||
fi
|
||||
|
||||
# Reload old nginx.service file
|
||||
do_and_check_cmd mv /lib/systemd/system/nginx.service.bak /lib/systemd/system/nginx.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
|
||||
# Remove /opt/bunkerized-nginx
|
||||
if [ -e "/opt/bunkerized-nginx" ] ; then
|
||||
echo "[*] Remove /opt/bunkerized-nginx"
|
||||
@@ -45,14 +54,16 @@ if [ -e "/opt/bunkerized-nginx" ] ; then
|
||||
fi
|
||||
|
||||
# Remove UI service
|
||||
if [ -e "/etc/systemd/system/bunkerized-nginx-ui.service" ] ; then
|
||||
echo "[*] Remove bunkerized-nginx-ui service"
|
||||
systemctl status bunkerized-nginx-ui > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "[*] Stop bunkerized-nginx-ui service"
|
||||
systemctl status nginx > /dev/null 2>&1
|
||||
do_and_check_cmd systemctl stop bunkerized-nginx-ui
|
||||
do_and_check_cmd systemctl disable bunkerized-nginx-ui
|
||||
do_and_check_cmd rm -f /etc/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
fi
|
||||
do_and_check_cmd systemctl disable bunkerized-nginx-ui
|
||||
do_and_check_cmd rm -f /lib/systemd/system/bunkerized-nginx-ui.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
|
||||
# Remove cron
|
||||
echo "[*] Remove cron"
|
||||
|
||||
Reference in New Issue
Block a user