Fixes/Tweaks

This commit is contained in:
th33xitus
2020-07-15 22:52:23 +02:00
parent 57d86b9ef4
commit a5155c50cc
9 changed files with 82 additions and 88 deletions

View File

@@ -390,7 +390,7 @@ switch_menu(){
esac
done
else
ERROR_MSG=" No klipper directory found! Download klipper first!"
ERROR_MSG=" No Klipper directory found! Download Klipper first!"
fi
}

View File

@@ -17,64 +17,64 @@ source_ini(){
start_klipper(){
if [ -e /etc/init.d/klipper ]; then
status_msg "Starting klipper service ..."
sudo /etc/init.d/klipper start && sleep 2 && ok_msg "Klipper service started!"
status_msg "Starting Klipper Service ..."
sudo /etc/init.d/klipper start && sleep 2 && ok_msg "Klipper Service started!"
fi
}
stop_klipper(){
if [ -e /etc/init.d/klipper ]; then
status_msg "Stopping klipper service ..."
sudo /etc/init.d/klipper stop && sleep 2 && ok_msg "Klipper service stopped!"
status_msg "Stopping Klipper Service ..."
sudo /etc/init.d/klipper stop && sleep 2 && ok_msg "Klipper Service stopped!"
fi
}
restart_klipper(){
if [ -e /etc/init.d/klipper ]; then
status_msg "Restarting klipper service ..."
sudo /etc/init.d/klipper restart && sleep 2 && ok_msg "Klipper service restarted!"
status_msg "Restarting Klipper Service ..."
sudo /etc/init.d/klipper restart && sleep 2 && ok_msg "Klipper Service restarted!"
fi
}
start_moonraker(){
if [ -e /etc/init.d/moonraker ]; then
status_msg "Starting moonraker service ..."
sudo /etc/init.d/moonraker start && sleep 2 && ok_msg "Moonraker service started!"
status_msg "Starting Moonraker Service ..."
sudo /etc/init.d/moonraker start && sleep 2 && ok_msg "Moonraker Service started!"
fi
}
stop_moonraker(){
if [ -e /etc/init.d/moonraker ]; then
status_msg "Stopping moonraker service ..."
sudo /etc/init.d/moonraker stop && sleep 2 && ok_msg "Moonraker service stopped!"
status_msg "Stopping Moonraker Service ..."
sudo /etc/init.d/moonraker stop && sleep 2 && ok_msg "Moonraker Service stopped!"
fi
}
restart_moonraker(){
if [ -e /etc/init.d/moonraker ]; then
status_msg "Restarting moonraker service ..."
sudo /etc/init.d/moonraker restart && sleep 2 && ok_msg "Moonraker service restarted!"
status_msg "Restarting Moonraker Service ..."
sudo /etc/init.d/moonraker restart && sleep 2 && ok_msg "Moonraker Service restarted!"
fi
}
start_octoprint(){
if [ -e /etc/init.d/octoprint ]; then
status_msg "Starting octoprint service ..."
sudo /etc/init.d/octoprint start && sleep 2 && ok_msg "Octoprint service started!"
status_msg "Starting OctoPrint Service ..."
sudo /etc/init.d/octoprint start && sleep 2 && ok_msg "OctoPrint Service started!"
fi
}
stop_octoprint(){
if [ -e /etc/init.d/octoprint ]; then
status_msg "Stopping octoprint service ..."
sudo /etc/init.d/octoprint stop && sleep 2 && ok_msg "Octoprint service stopped!"
status_msg "Stopping OctoPrint Service ..."
sudo /etc/init.d/octoprint stop && sleep 2 && ok_msg "OctoPrint Service stopped!"
fi
}
restart_octoprint(){
if [ -e /etc/init.d/octoprint ]; then
status_msg "Restarting octoprint service ..."
sudo /etc/init.d/octoprint restart && sleep 2 && ok_msg "Octoprint service restarted!"
status_msg "Restarting OctoPrint Service ..."
sudo /etc/init.d/octoprint restart && sleep 2 && ok_msg "OctoPrint Service restarted!"
fi
}
@@ -94,7 +94,6 @@ dep_check(){
sudo apt-get install ${install[@]} -y && ok_msg "Dependencies installed!"
break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
esac
done
fi
@@ -118,22 +117,20 @@ print_error(){
}
pkg_check(){
status_msg "Checking if nginx is installed"
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]]; then
echo "nginx found!"
else
echo "nginx was not found, installing..." 2>&1
sudo apt-get -y install nginx 2>/dev/null
fi
#WIP
if [[ $(dpkg-query -f'${Status}' --show $PKG 2>/dev/null) = *\ installed ]]; then
else
sudo apt-get -y install nginx 2>/dev/null
fi
}
build_fw(){
if [ -d $KLIPPER_DIR ]; then
cd $KLIPPER_DIR && make menuconfig
status_msg "Building firmware ..."
status_msg "Building Firmware ..."
make clean && make && ok_msg "Firmware built!"
else
warn_msg "Can not build firmware without a Klipper directory!"
warn_msg "Can not build Firmware without a Klipper directory!"
fi
}
@@ -186,7 +183,7 @@ PRINTERID
flash_routine(){
echo -e "/=================================================\ "
echo -e "| ATTENTION! |"
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
echo -e "| Flashing a Smoothie based board for the first |"
echo -e "| time with this script will certainly fail. |"
echo -e "| This applies to boards like the BTT SKR V1.3 or |"
@@ -221,12 +218,12 @@ flash_mcu(){
}
enable_octoprint_service(){
status_msg "Octoprint Service is disabled! Enabling now ..."
status_msg "OctoPrint Service is disabled! Enabling now ..."
sudo systemctl enable octoprint -q && sudo systemctl start octoprint
}
disable_octoprint_service(){
status_msg "Octoprint Service is enabled! Disabling now ..."
status_msg "OctoPrint Service is enabled! Disabling now ..."
sudo systemctl stop octoprint && sudo systemctl disable octoprint -q
}
@@ -234,18 +231,18 @@ toggle_octoprint_service(){
if systemctl is-enabled octoprint.service -q; then
disable_octoprint_service
sleep 2
CONFIRM_MSG=" Octoprint Service is now >>> DISABLED <<< !"
CONFIRM_MSG=" OctoPrint Service is now >>> DISABLED <<< !"
else
enable_octoprint_service
sleep 2
CONFIRM_MSG=" Octoprint Service is now >>> ENABLED <<< !"
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
fi
}
read_octoprint_service_status(){
if ! systemctl is-enabled octoprint.service -q; then
OPRINT_SERVICE_STATUS="${green}[Enable]${default} Octoprint service "
OPRINT_SERVICE_STATUS="${green}[Enable]${default} OctoPrint Service "
else
OPRINT_SERVICE_STATUS="${red}[Disable]${default} Octoprint service "
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
fi
}

View File

@@ -37,11 +37,11 @@ install_tornado(){
install_dwc2fk(){
cd ${HOME}
status_msg "Cloning dwc2-for-klipper repository ..."
git clone $DWC2FK_REPO && ok_msg "dwc2-for-klipper successfully cloned!"
status_msg "Cloning DWC2-for-Klipper repository ..."
git clone $DWC2FK_REPO && ok_msg "DWC2-for-Klipper successfully cloned!"
#create a web_dwc2.py symlink if not already existing
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $KLIPPER_DIR/klippy/extras/web_dwc2.py ]; then
status_msg "Creating web_dwc2.py symlink ..."
status_msg "Creating web_dwc2.py Symlink ..."
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py && ok_msg "Symlink created!"
fi
}
@@ -54,7 +54,6 @@ dwc2fk_cfg(){
case "$yn" in
Y|y|Yes|yes|"") create_dwc2fk_cfg; break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; dwc2fk_cfg;;
esac
done
}
@@ -143,7 +142,6 @@ install_dwc2(){
webcam_dep_check && ok_msg "Dependencies installed!"
break;;
N|n|No|no) break;;
*) echo "Unknown parameter: $yn"; echo;;
esac
done
#the update_dwc2 function does the same as installing dwc2

View File

@@ -1,19 +1,19 @@
install_klipper(){
if [ -e /etc/init.d/klipper ] && [ -e /etc/default/klipper ]; then
ERROR_MSG=" Looks like klipper is already installed!\n Skipping ..."
ERROR_MSG=" Looks like Klipper is already installed!\n Skipping ..."
else
#check for dependencies
dep=(git)
dep_check
#execute operation
cd ${HOME}
status_msg "Cloning klipper repository ..."
status_msg "Cloning Klipper repository ..."
git clone $KLIPPER_REPO && ok_msg "Klipper successfully cloned!"
status_msg "Installing klipper service ..."
status_msg "Installing Klipper Service ..."
$KLIPPER_DIR/scripts/install-octopi.sh && sleep 2 && ok_msg "Klipper installation complete!"
#create a klippy.log symlink in home-dir just for convenience
if [ ! -e ${HOME}/klippy.log ]; then
status_msg "Creating klippy.log symlink ..."
status_msg "Creating klippy.log Symlink ..."
ln -s /tmp/klippy.log ${HOME}/klippy.log && ok_msg "Symlink created!"
fi
while true; do
@@ -23,7 +23,6 @@ install_klipper(){
case "$yn" in
Y|y|Yes|yes|"") build_fw && flash_routine; break;;
N|n|No|no) break;;
*) warn_msg "Unknown parameter: $yn"; echo;;
esac
done
fi

View File

@@ -18,7 +18,7 @@ mainsail_install_routine(){
install_nginx
test_api
test_nginx
install_mainsail && ok_msg "Mainsail install complete!"; echo
install_mainsail && ok_msg "Mainsail installation complete!"; echo
fi
else
ERROR_MSG=" Please install Klipper first!\n Skipping..."
@@ -39,7 +39,7 @@ install_moonraker(){
ln -s /tmp/moonraker.log ${HOME}/moonraker.log && ok_msg "Symlink created!"
fi
else
ERROR_MSG=" You are not using a moonraker fork\n Please switch to a moonraker fork first! Aborting ..."
ERROR_MSG=" You are not using a Moonraker fork\n Please switch to a Moonraker fork first! Aborting ..."
ERROR=1
fi
}
@@ -88,9 +88,9 @@ check_api_section(){
status_msg "Checking for api_server configuration ..."
# check if api server is present in printer.cfg
if [ $(grep '^\[api_server\]$' $PRINTER_CFG) ]; then
ok_msg "API server already configured"
ok_msg "API Server already configured"
else
status_msg "No API server entry found."
status_msg "No API Server entry found."
status_msg "Configuring API server..."
# append the following lines to printer.cfg
cat <<API >> $PRINTER_CFG

View File

@@ -37,7 +37,7 @@ octoprint_dependencies(){
install_octoprint(){
if [ ! -d $OCTOPRINT_DIR ];then
status_msg "Create Octoprint directory ..."
status_msg "Create OctoPrint directory ..."
mkdir -p $OCTOPRINT_DIR && ok_msg "Directory created!"
fi
cd $OCTOPRINT_DIR
@@ -46,7 +46,7 @@ install_octoprint(){
virtualenv venv
source venv/bin/activate
#install octoprint with pip
status_msg "Download and install octoprint ..."
status_msg "Download and install OctoPrint ..."
pip install pip --upgrade
pip install --no-cache-dir octoprint
ok_msg "Download complete!"
@@ -57,11 +57,11 @@ install_octoprint(){
add_groups(){
USER=$(whoami)
if [[ ! $(groups | grep tty) ]]; then
status_msg "Adding the current user to group 'tty' ..."
status_msg "Adding user '$USER' to group 'tty' ..."
sudo usermod -a -G tty $USER && ok_msg "Done!"
fi
if [[ ! $(groups | grep tty) ]]; then
status_msg "Adding the current user to group 'dialout' ..."
status_msg "Adding user '$USER' to group 'dialout' ..."
sudo usermod -a -G dialout $USER && ok_msg "Done!"
fi
}
@@ -74,7 +74,7 @@ configure_autostart(){
wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.default
ok_msg "Files downloaded successfully!"
#make necessary changes in default file
status_msg "Configure octoprint service ..."
status_msg "Configure OctoPrint Service ..."
DEFAULT_FILE=$OCTOPRINT_DIR/octoprint.default
sed -i "s/pi/$USER/g" $DEFAULT_FILE
sed -i "s/#BASEDIR=/BASEDIR=/" $DEFAULT_FILE
@@ -89,7 +89,7 @@ configure_autostart(){
sudo update-rc.d octoprint defaults
sudo systemctl daemon-reload
ok_msg "Configuration complete!"
ok_msg "Octoprint installed!"
ok_msg "OctoPrint installed!"
}
add_reboot_permission(){
@@ -112,10 +112,10 @@ load_server(){
start_octoprint
#create an octoprint.log symlink in home-dir just for convenience
if [ ! -e ${HOME}/octoprint.log ]; then
status_msg "Creating octoprint.log symlink ..."
status_msg "Creating octoprint.log Symlink ..."
ln -s ${HOME}/.octoprint/logs/octoprint.log ${HOME}/octoprint.log && ok_msg "Symlink created!"
fi
ok_msg "Octoprint is now running on:"
ok_msg "OctoPrint is now running on:"
ok_msg "$(hostname -I | cut -d " " -f1):5000 or"
ok_msg "http://localhost:5000"; echo
}

View File

@@ -10,16 +10,16 @@ remove_klipper(){
if [ "$ERROR_MSG" = "" ]; then
stop_klipper
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
status_msg "Removing klipper service ..."
status_msg "Removing Klipper Service ..."
sudo update-rc.d -f klipper remove
sudo rm -rf /etc/init.d/klipper /etc/default/klipper && ok_msg "Klipper service removed!"
sudo rm -rf /etc/init.d/klipper /etc/default/klipper && ok_msg "Klipper Service removed!"
fi
if [[ -d $KLIPPER_DIR || -d $KLIPPY_ENV_DIR ]]; then
status_msg "Removing klipper and klippy-env directory ..."
status_msg "Removing Klipper and klippy-env directory ..."
rm -rf $KLIPPER_DIR $KLIPPY_ENV_DIR && ok_msg "Directories removed!"
fi
if [[ -L ${HOME}/klippy.log || -e /tmp/klippy.log ]]; then
status_msg "Removing klippy.log symlink ..."
status_msg "Removing klippy.log Symlink ..."
rm -rf ${HOME}/klippy.log /tmp/klippy.log && ok_msg "Symlink removed!"
fi
ok_msg "Klipper successfully removed!"
@@ -37,19 +37,19 @@ remove_dwc2(){
print_error "DWC2-for-Klipper &\n DWC2 Web UI" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
if [ -d $DWC2FK_DIR ]; then
status_msg "Removing dwc2-for-klipper directory ..."
status_msg "Removing DWC2-for-Klipper directory ..."
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
fi
if [ -d $TORNADO_DIR1 ]; then
status_msg "Removing tornado from klippy-env ..."
status_msg "Removing Tornado from klippy-env ..."
rm -rf $TORNADO_DIR1 $TORNADO_DIR2 && ok_msg "Tornado removed!"
fi
if [ -e $WEB_DWC2 ]; then
status_msg "Removing web_dwc2.py symlink from klippy ..."
status_msg "Removing web_dwc2.py Symlink from klippy ..."
rm -rf $WEB_DWC2 && ok_msg "File removed!"
fi
if [ -d $DWC2_DIR ]; then
status_msg "Removing dwc2 directory ..."
status_msg "Removing DWC2 directory ..."
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
fi
ok_msg "DWC2-for-Klipper & DWC2 Web UI successfully removed!"
@@ -75,33 +75,33 @@ remove_mainsail(){
stop_moonraker
#remove moonraker services
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
status_msg "Removing moonraker service ..."
status_msg "Removing Moonraker Service ..."
sudo update-rc.d -f moonraker remove
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker && ok_msg "Moonraker service removed!"
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker && ok_msg "Moonraker Service removed!"
fi
#remove mainsail dir
if [ -d $MAINSAIL_DIR ]; then
status_msg "Removing mainsail directory ..."
status_msg "Removing Mainsail directory ..."
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
fi
#remove moonraker-env
if [ -d ${HOME}/moonraker-env ]; then
status_msg "Removing moonraker virtualenv ..."
status_msg "Removing Moonraker virtualenv ..."
rm -rf ${HOME}/moonraker-env && ok_msg "Directory removed!"
fi
#remove moonraker.log symlink
if [[ -L ${HOME}/moonraker.log || -e /tmp/moonraker.log ]]; then
status_msg "Removing moonraker.log symlink ..."
status_msg "Removing moonraker.log Symlink ..."
rm -rf ${HOME}/moonraker.log /tmp/moonraker.log && ok_msg "Symlink removed!"
fi
#remove mainsail cfg
if [ -e /etc/nginx/sites-available/mainsail ]; then
status_msg "Removing mainsail configuration for nginx ..."
status_msg "Removing Mainsail configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
fi
#remove mainsail symlink
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
status_msg "Removing mainsail symlink for nginx ..."
status_msg "Removing Mainsail Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
fi
#remove legacy api key
@@ -124,18 +124,18 @@ remove_nginx(){
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]] ; then
while true; do
echo
read -p "Do you want to completely remove (purge) nginx? (Y/n): " yn
read -p "Do you want to completely remove (purge) Nginx? (Y/n): " yn
case "$yn" in
Y|y|Yes|yes|"")
status_msg "Stopping and removing nginx service ..."
status_msg "Stopping and removing Nginx Service ..."
if [ -e /etc/init.d/nginx ]; then
sudo /etc/init.d/nginx stop && ok_msg "Nginx service stopped!"
sudo rm /etc/init.d/nginx && ok_msg "Nginx service removed!"
sudo /etc/init.d/nginx stop && ok_msg "Nginx Service stopped!"
sudo rm /etc/init.d/nginx && ok_msg "Nginx Service removed!"
fi
if [ -e /etc/default/nginx ]; then
sudo rm /etc/default/nginx
fi
status_msg "Purging nginx from system ..."
status_msg "Purging Nginx from system ..."
sudo apt-get purge nginx nginx-common -y && ok_msg "Nginx removed!"
break;;
N|n|No|no) break;;
@@ -153,25 +153,25 @@ remove_octoprint(){
${HOME}/octoprint.log
/etc/sudoers.d/octoprint-shutdown
)
print_error "Octoprint" && data_count=()
print_error "OctoPrint" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
stop_octoprint
if [[ -e $OCTOPRINT_SERVICE1 || -e $OCTOPRINT_SERVICE2 ]]; then
status_msg "Removing octoprint service ..."
status_msg "Removing OctoPrint Service ..."
sudo update-rc.d -f octoprint remove
sudo rm -rf $OCTOPRINT_SERVICE1 $OCTOPRINT_SERVICE2 && ok_msg "Octoprint service removed!"
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 ..."
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 ..."
status_msg "Removing octoprint.log Symlink ..."
rm -rf ${HOME}/octoprint.log && ok_msg "Symlink removed!"
fi
ok_msg "Octoprint successfully removed!"; echo
ok_msg "OctoPrint successfully removed!"; echo
fi
}

View File

@@ -91,7 +91,7 @@ remove_ui(){
hr
echo -e "| Files and directories which remain untouched: | "
echo -e "| --> ~/printer.cfg | "
echo -e "| --> ~/backup | "
echo -e "| --> ~/kiauh-backups | "
echo -e "| You need remove them manually if you wish so. | "
hr
echo -e "| 1) [Klipper] | | "
@@ -114,7 +114,7 @@ advanced_ui(){
echo -e "| 3) [Flash MCU] | "
echo -e "| 4) [Get Printer-ID] | "
echo -e "| 5) [Write Printer-ID to printer.cfg] | "
echo -e "| 6) [Write DWC2-for-klipper config] | "
echo -e "| 6) [Write DWC2-for-Klipper config] | "
echo -e "| | "
quit_footer
}
@@ -141,7 +141,7 @@ switch_ui(){
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
bottom_border
echo
echo -e " $(title_msg "Active branch: ")${green}$GET_BRANCH${default}"
echo -e " $(title_msg "Active Branch: ")${green}$GET_BRANCH${default}"
echo
top_border
echo -e "| 1) [--> origin/master] | "

View File

@@ -40,7 +40,7 @@ update_dwc2fk(){
cd $DWC2FK_DIR && git pull
#create a web_dwc2.py symlink if not already existing
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $WEB_DWC2 ]; then
status_msg "Creating web_dwc2.py symlink ..."
status_msg "Creating web_dwc2.py Symlink ..."
ln -s $DWC2FK_DIR/web_dwc2.py $WEB_DWC2 && ok_msg "Symlink created!"
fi
fi