fix: add python check to moonraker installer

This commit is contained in:
th33xitus
2020-11-13 21:20:48 +01:00
parent 4f7ac68af6
commit 3b74bb0b77

View File

@@ -1,23 +1,27 @@
install_moonraker(){ install_moonraker(){
system_check_moonraker if [ $(python3 --version | cut -d"." -f2) -ge 7 ]; then
#ask user for customization system_check_moonraker
get_user_selections_moonraker #ask user for customization
#disable/remove haproxy/lighttpd get_user_selections_moonraker
handle_haproxy_lighttpd #disable/remove haproxy/lighttpd
#moonraker main installation handle_haproxy_lighttpd
moonraker_setup #moonraker main installation
check_for_folder_moonraker moonraker_setup
#setup configs check_for_folder_moonraker
setup_printer_config_moonraker #setup configs
setup_moonraker_conf setup_printer_config_moonraker
#execute customizations setup_moonraker_conf
write_custom_trusted_clients #execute customizations
symlinks_moonraker write_custom_trusted_clients
disable_octoprint symlinks_moonraker
#after install actions disable_octoprint
restart_moonraker #after install actions
restart_klipper restart_moonraker
#test_api restart_klipper
else
ERROR_MSG="Python 3.7 or above required!\n Please upgrade your Python version first."
print_msg && clear_msg
fi
} }
system_check_moonraker(){ system_check_moonraker(){
@@ -247,8 +251,7 @@ moonraker_setup(){
$MOONRAKER_DIR/scripts/install-moonraker.sh $MOONRAKER_DIR/scripts/install-moonraker.sh
#copy moonraker configuration for nginx to /etc/nginx/conf.d #copy moonraker configuration for nginx to /etc/nginx/conf.d
setup_moonraker_nginx_cfg setup_moonraker_nginx_cfg
#backup a possible existing printer.cfg at the old location #backup a possible existing printer.cfg at the old location and before patching in the new location
#and before patching in the new location
backup_printer_cfg backup_printer_cfg
patch_klipper_sysfile "moonraker" patch_klipper_sysfile "moonraker"
#re-run printer.cfg location function to read the new path for the printer.cfg #re-run printer.cfg location function to read the new path for the printer.cfg
@@ -355,7 +358,7 @@ setup_moonraker_conf(){
ok_msg "Trusted clients written!" ok_msg "Trusted clients written!"
fi fi
#check for at least one trusted client in an already existing moonraker.conf #check for at least one trusted client in an already existing moonraker.conf
#in no entry is found, write default trusted client #if no entry is found, write default trusted client
if [ "$MOONRAKER_CONF_FOUND" = "true" ]; then if [ "$MOONRAKER_CONF_FOUND" = "true" ]; then
if grep "trusted_clients:" ${HOME}/moonraker.conf -q; then if grep "trusted_clients:" ${HOME}/moonraker.conf -q; then
TC_LINE=$(grep -n "trusted_clients:" ${HOME}/moonraker.conf | cut -d ":" -f1) TC_LINE=$(grep -n "trusted_clients:" ${HOME}/moonraker.conf | cut -d ":" -f1)
@@ -468,8 +471,7 @@ write_custom_trusted_clients(){
} }
symlinks_moonraker(){ symlinks_moonraker(){
#create a klippy.log/moonraker.log symlink in #create a klippy.log/moonraker.log symlink in klipper_config-dir just for convenience
#klipper_config-dir just for convenience
if [ "$SEL_KLIPPYLOG_SL" = "true" ] && [ ! -e ${HOME}/klipper_config/klippy.log ]; then if [ "$SEL_KLIPPYLOG_SL" = "true" ] && [ ! -e ${HOME}/klipper_config/klippy.log ]; then
status_msg "Creating klippy.log symlink ..." status_msg "Creating klippy.log symlink ..."
ln -s /tmp/klippy.log ${HOME}/klipper_config ln -s /tmp/klippy.log ${HOME}/klipper_config