mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 02:54:28 +05:00
fix: rework octoprint remove function for removing multi instances
This commit is contained in:
3
kiauh.sh
3
kiauh.sh
@@ -35,9 +35,6 @@ DWC_ENV_DIR=${HOME}/dwc-env
|
|||||||
DWC2_DIR=${HOME}/sdcard/web
|
DWC2_DIR=${HOME}/sdcard/web
|
||||||
#octoprint
|
#octoprint
|
||||||
OCTOPRINT_DIR=${HOME}/OctoPrint
|
OCTOPRINT_DIR=${HOME}/OctoPrint
|
||||||
OCTOPRINT_CFG_DIR=${HOME}/.octoprint
|
|
||||||
OCTOPRINT_SERVICE1=/etc/init.d/octoprint
|
|
||||||
OCTOPRINT_SERVICE2=/etc/default/octoprint
|
|
||||||
#KlipperScreen
|
#KlipperScreen
|
||||||
KLIPPERSCREEN_DIR=${HOME}/KlipperScreen
|
KLIPPERSCREEN_DIR=${HOME}/KlipperScreen
|
||||||
KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env
|
KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ remove_klipper(){
|
|||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###remove multi instance logfiles
|
###remove multi instance logfiles
|
||||||
if [ "$(find /tmp -maxdepth 1 -name "klippy-*.log")" ]; then
|
if [ "$(find /tmp -maxdepth 1 -name "klippy-*.log")" ]; then
|
||||||
for logfile in $(find /tmp -maxdepth 1 -name "klippy-*.log")
|
for logfile in $(find /tmp -maxdepth 1 -name "klippy-*.log")
|
||||||
@@ -47,6 +48,7 @@ remove_klipper(){
|
|||||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###remove multi instance UDS
|
###remove multi instance UDS
|
||||||
if [ "$(find /tmp -maxdepth 1 -name "klippy_uds-*")" ]; then
|
if [ "$(find /tmp -maxdepth 1 -name "klippy_uds-*")" ]; then
|
||||||
for uds in $(find /tmp -maxdepth 1 -name "klippy_uds-*")
|
for uds in $(find /tmp -maxdepth 1 -name "klippy_uds-*")
|
||||||
@@ -54,6 +56,7 @@ remove_klipper(){
|
|||||||
status_msg "Removing $uds ..." && rm -f $uds && ok_msg "Done!"
|
status_msg "Removing $uds ..." && rm -f $uds && ok_msg "Done!"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###remove multi instance tmp-printer
|
###remove multi instance tmp-printer
|
||||||
if [ "$(find /tmp -maxdepth 1 -name "printer-*")" ]; then
|
if [ "$(find /tmp -maxdepth 1 -name "printer-*")" ]; then
|
||||||
for tmp_printer in $(find /tmp -maxdepth 1 -name "printer-*")
|
for tmp_printer in $(find /tmp -maxdepth 1 -name "printer-*")
|
||||||
@@ -271,47 +274,43 @@ remove_fluidd(){
|
|||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
remove_octoprint(){
|
remove_octoprint(){
|
||||||
data_arr=(
|
###remove single instance
|
||||||
$OCTOPRINT_SERVICE1
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "octoprint.service")" ]; then
|
||||||
$OCTOPRINT_SERVICE2
|
status_msg "Removing OctoPrint Service ..."
|
||||||
$OCTOPRINT_DIR
|
sudo systemctl stop octoprint
|
||||||
$OCTOPRINT_CFG_DIR
|
sudo systemctl disable octoprint
|
||||||
${HOME}/octoprint.log
|
sudo rm -f $SYSTEMDDIR/octoprint.service
|
||||||
/etc/sudoers.d/octoprint-shutdown
|
ok_msg "OctoPrint Service removed!"
|
||||||
/etc/nginx/sites-available/octoprint
|
|
||||||
/etc/nginx/sites-enabled/octoprint
|
|
||||||
)
|
|
||||||
print_error "OctoPrint" && data_count=()
|
|
||||||
if [ "$ERROR_MSG" = "" ]; then
|
|
||||||
stop_octoprint
|
|
||||||
if [[ -e $OCTOPRINT_SERVICE1 || -e $OCTOPRINT_SERVICE2 ]]; then
|
|
||||||
status_msg "Removing OctoPrint Service ..."
|
|
||||||
sudo update-rc.d -f octoprint remove
|
|
||||||
sudo rm -rf $OCTOPRINT_SERVICE1 $OCTOPRINT_SERVICE2 && ok_msg "OctoPrint Service removed!"
|
|
||||||
fi
|
|
||||||
if [[ -d $OCTOPRINT_DIR || -d $OCTOPRINT_CFG_DIR ]]; then
|
|
||||||
status_msg "Removing OctoPrint and .octoprint directory ..."
|
|
||||||
rm -rf $OCTOPRINT_DIR $OCTOPRINT_CFG_DIR && ok_msg "Directories removed!"
|
|
||||||
fi
|
|
||||||
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
|
||||||
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
|
|
||||||
fi
|
|
||||||
if [ -L ${HOME}/octoprint.log ]; then
|
|
||||||
status_msg "Removing octoprint.log Symlink ..."
|
|
||||||
rm -rf ${HOME}/octoprint.log && ok_msg "Symlink removed!"
|
|
||||||
fi
|
|
||||||
#remove octoprint config for nginx
|
|
||||||
if [ -e /etc/nginx/sites-available/octoprint ]; then
|
|
||||||
status_msg "Removing OctoPrint configuration for Nginx ..."
|
|
||||||
sudo rm /etc/nginx/sites-available/octoprint && ok_msg "File removed!"
|
|
||||||
fi
|
|
||||||
#remove octoprint symlink for nginx
|
|
||||||
if [ -L /etc/nginx/sites-enabled/octoprint ]; then
|
|
||||||
status_msg "Removing OctoPrint Symlink for Nginx ..."
|
|
||||||
sudo rm /etc/nginx/sites-enabled/octoprint && ok_msg "File removed!"
|
|
||||||
fi
|
|
||||||
CONFIRM_MSG=" OctoPrint successfully removed!"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
###remove multi instance services
|
||||||
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "octoprint-[[:digit:]].service")" ]; then
|
||||||
|
status_msg "Removing OctoPrint Services ..."
|
||||||
|
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "octoprint-*.service" | cut -d"/" -f5)
|
||||||
|
do
|
||||||
|
status_msg "Removing $service ..."
|
||||||
|
sudo systemctl stop $service
|
||||||
|
sudo systemctl disable $service
|
||||||
|
sudo rm -f $SYSTEMDDIR/$service
|
||||||
|
ok_msg "OctoPrint Service removed!"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
###reloading units
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
### remove .octoprint directories
|
||||||
|
if [ -d ${HOME}/OctoPrint ] || [ -d ${HOME}/.octoprint* ]; then
|
||||||
|
status_msg "Removing OctoPrint and .octoprint directory ..."
|
||||||
|
rm -rf ${HOME}/OctoPrint ${HOME}/.octoprint* && ok_msg "Directories removed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
### remove sudoers file
|
||||||
|
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
||||||
|
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONFIRM_MSG=" OctoPrint successfully removed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user