soscmd/soscmd-startup

39 lines
1.4 KiB
Text
Raw Normal View History

2023-06-03 11:28:50 +02:00
#!/bin/bash
if [ "$1" == "on" ]; then
if [ ! "$SOSCMD_STARTUP_SILENCE" == "true" ]; then echo ":: Enabling startup mode";fi
systemctl stop httpd
if [ ! -d "/etc/httpd/conf/sites-enabled-startup" ]; then
echo ":: Error: Already in startup mode."
exit 1
fi
mv "/etc/httpd/conf/sites-enabled" "/etc/httpd/conf/sites-enabled-runtime"
mv "/etc/httpd/conf/sites-enabled-startup" "/etc/httpd/conf/sites-enabled"
if [ "$SOSCMD_STARTUP_WEBSERVER" == "true" ]; then
systemctl start httpd
fi
exit 0
elif [ "$1" == "off" ]; then
if [ ! "$SOSCMD_STARTUP_SILENCE" == "true" ]; then echo ":: Disabling startup mode";fi
systemctl stop httpd
if [ -d "/etc/httpd/conf/sites-enabled-startup" ]; then
echo ":: Error: Already in runtime mode."
exit 2
fi
mv "/etc/httpd/conf/sites-enabled" "/etc/httpd/conf/sites-enabled-startup"
mv "/etc/httpd/conf/sites-enabled-runtime" "/etc/httpd/conf/sites-enabled"
if [ "$SOSCMD_STARTUP_WEBSERVER" == "true" ]; then
systemctl start httpd
fi
exit 0
else
echo ":: Error: Invalid argument. Use 'on' or 'off' to manage startup mode."
if [ "$SOSCMD_STARTUP_WEBSERVER" == "true" ]; then
echo ":: Oh, and it seems like \"SOSCMD_STARTUP_WEBSERVER\" is set."
echo ":: The webserver will start automatically if set to true."
else
echo ":: For starting apache2 automatically, set \"SOSCMD_STARTUP_WEBSERVER\""
echo ":: to true. You must start it manually if not set to true."
fi
exit 99
fi