add: variable triggered function to disable octoprint service

This commit is contained in:
th33xitus
2020-08-22 17:48:52 +02:00
parent eb6b2465c7
commit 2be2ce12c6

View File

@@ -246,6 +246,12 @@ enable_octoprint_service(){
fi fi
} }
disable_octoprint(){
if [ "$DISABLE_OPRINT" = "true" ]; then
disable_octoprint_service
fi
}
disable_octoprint_service(){ disable_octoprint_service(){
if [[ -f $OCTOPRINT_SERVICE1 && -f $OCTOPRINT_SERVICE2 ]]; then if [[ -f $OCTOPRINT_SERVICE1 && -f $OCTOPRINT_SERVICE2 ]]; then
status_msg "OctoPrint Service is enabled! Disabling now ..." status_msg "OctoPrint Service is enabled! Disabling now ..."
@@ -278,27 +284,29 @@ read_octoprint_service_status(){
} }
create_reverse_proxy(){ create_reverse_proxy(){
#check for dependencies if [ "$SET_REVERSE_PROXY" = "true" ]; then
dep=(nginx) #check for dependencies
dependency_check dep=(nginx)
#execute operations dependency_check
status_msg "Creating Nginx configuration for $1 ..." #execute operations
cat ${HOME}/kiauh/resources/$1_nginx.cfg > ${HOME}/kiauh/resources/$1 status_msg "Creating Nginx configuration for $1 ..."
sudo mv ${HOME}/kiauh/resources/$1 /etc/nginx/sites-available/$1 cat ${HOME}/kiauh/resources/$1_nginx.cfg > ${HOME}/kiauh/resources/$1
#ONLY FOR MAINSAIL: replace username if not "pi" sudo mv ${HOME}/kiauh/resources/$1 /etc/nginx/sites-available/$1
if [ "$1" = "mainsail" ]; then #ONLY FOR MAINSAIL: replace username if not "pi"
sudo sed -i "/root/s/pi/${USER}/" /etc/nginx/sites-available/mainsail if [ "$1" = "mainsail" ]; then
sudo sed -i "/root/s/pi/${USER}/" /etc/nginx/sites-available/mainsail
fi
ok_msg "Nginx configuration for $1 was set!"
#remove default config
if [ -e /etc/nginx/sites-enabled/default ]; then
sudo rm /etc/nginx/sites-enabled/default
fi fi
ok_msg "Nginx configuration for $1 was set!" #create symlink for own configs
#remove default config if [ ! -e /etc/nginx/sites-enabled/$1 ]; then
if [ -e /etc/nginx/sites-enabled/default ]; then sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default fi
restart_nginx
fi fi
#create symlink for own configs
if [ ! -e /etc/nginx/sites-enabled/$1 ]; then
sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
fi
restart_nginx
} }
create_custom_hostname(){ create_custom_hostname(){
@@ -308,7 +316,7 @@ create_custom_hostname(){
echo -e "| that name to open the Interface in your browser. |" echo -e "| that name to open the Interface in your browser. |"
echo -e "| |" echo -e "| |"
echo -e "| Example: If you set the hostname to 'my-printer' |" echo -e "| Example: If you set the hostname to 'my-printer' |"
echo -e "| you can open Mainsail/Octoprint by |" echo -e "| you can open DWC2/Mainsail/Octoprint by |"
echo -e "| browsing to: http://my-printer.local |" echo -e "| browsing to: http://my-printer.local |"
bottom_border bottom_border
while true; do while true; do