mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-15 03:24:29 +05:00
fix: use new method to locate printer.cfg, rework depending functions
This commit is contained in:
1
kiauh.sh
1
kiauh.sh
@@ -34,7 +34,6 @@ OCTOPRINT_SERVICE2=/etc/default/octoprint
|
|||||||
#misc
|
#misc
|
||||||
INI_FILE=${HOME}/kiauh/kiauh.ini
|
INI_FILE=${HOME}/kiauh/kiauh.ini
|
||||||
BACKUP_DIR=${HOME}/kiauh-backups
|
BACKUP_DIR=${HOME}/kiauh-backups
|
||||||
PRINTER_CFG=${HOME}/printer.cfg
|
|
||||||
|
|
||||||
### set github repos
|
### set github repos
|
||||||
KLIPPER_REPO=https://github.com/KevinOConnor/klipper.git
|
KLIPPER_REPO=https://github.com/KevinOConnor/klipper.git
|
||||||
|
|||||||
@@ -11,6 +11,20 @@ check_euid(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locate_printer_cfg(){
|
||||||
|
if [ -f $KLIPPER_SERVICE2 ]; then
|
||||||
|
#reads /etc/default/klipper and gets the default printer.cfg location
|
||||||
|
PRINTER_CFG_LOC=$(grep "KLIPPY_ARGS=" /etc/default/klipper | cut -d" " -f2)
|
||||||
|
if [ -e $PRINTER_CFG_LOC ]; then
|
||||||
|
PRINTER_CFG=$(readlink -e $PRINTER_CFG_LOC)
|
||||||
|
else
|
||||||
|
PRINTER_CFG=""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
PRINTER_CFG=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
source_ini(){
|
source_ini(){
|
||||||
source ${HOME}/kiauh/kiauh.ini
|
source ${HOME}/kiauh/kiauh.ini
|
||||||
}
|
}
|
||||||
@@ -316,4 +330,4 @@ remove_branding(){
|
|||||||
N|n|No|no) break;;
|
N|n|No|no) break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ install_dwc2(){
|
|||||||
#ask user for customization
|
#ask user for customization
|
||||||
get_user_selections_dwc2
|
get_user_selections_dwc2
|
||||||
#dwc2 main installation
|
#dwc2 main installation
|
||||||
check_for_folder_dwc2
|
|
||||||
tornado_setup
|
tornado_setup
|
||||||
dwc2fk_setup
|
|
||||||
dwc2_setup
|
dwc2_setup
|
||||||
#setup config
|
#setup config
|
||||||
write_printer_cfg_dwc2
|
write_printer_cfg_dwc2
|
||||||
@@ -25,10 +23,11 @@ install_dwc2(){
|
|||||||
system_check_dwc2(){
|
system_check_dwc2(){
|
||||||
status_msg "Initializing DWC2 installation ..."
|
status_msg "Initializing DWC2 installation ..."
|
||||||
stop_klipper
|
stop_klipper
|
||||||
|
check_for_folder_dwc2
|
||||||
#check for existing printer.cfg
|
#check for existing printer.cfg
|
||||||
if [ -e ${HOME}/printer.cfg ]; then
|
locate_printer_cfg
|
||||||
|
if [ ! -z $PRINTER_CFG ]; then
|
||||||
PRINTER_CFG_FOUND="true"
|
PRINTER_CFG_FOUND="true"
|
||||||
PRINTER_CFG_LOC="${HOME}/printer.cfg"
|
|
||||||
else
|
else
|
||||||
PRINTER_CFG_FOUND="false"
|
PRINTER_CFG_FOUND="false"
|
||||||
fi
|
fi
|
||||||
@@ -59,8 +58,8 @@ get_user_selections_dwc2(){
|
|||||||
echo -e "| option or error will prevent DWC2 from loading and |"
|
echo -e "| option or error will prevent DWC2 from loading and |"
|
||||||
echo -e "| you need to check klippy.log to resolve the error. |"
|
echo -e "| you need to check klippy.log to resolve the error. |"
|
||||||
echo -e "| |"
|
echo -e "| |"
|
||||||
echo -e "| Neither option 1 or 2 of this script will create a |"
|
echo -e "| ${red}Neither option 1 or 2 of this script will create a |"
|
||||||
echo -e "| fully working printer.cfg for you! |"
|
echo -e "| fully working printer.cfg for you!${default} |"
|
||||||
hr
|
hr
|
||||||
echo -e "| 1) [Create default configuration] |"
|
echo -e "| 1) [Create default configuration] |"
|
||||||
echo -e "| 2) [Create custom configuration] |"
|
echo -e "| 2) [Create custom configuration] |"
|
||||||
@@ -142,32 +141,40 @@ tornado_setup(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dwc2fk_setup(){
|
dwc2_setup(){
|
||||||
|
#check dependencies
|
||||||
|
dep=(git wget gzip tar curl)
|
||||||
|
dependency_check
|
||||||
|
#get dwc2-for-klipper
|
||||||
cd ${HOME}
|
cd ${HOME}
|
||||||
status_msg "Cloning DWC2-for-Klipper repository ..."
|
status_msg "Cloning DWC2-for-Klipper repository ..."
|
||||||
git clone $DWC2FK_REPO && ok_msg "DWC2-for-Klipper successfully cloned!"
|
git clone $DWC2FK_REPO
|
||||||
|
ok_msg "DWC2-for-Klipper successfully cloned!"
|
||||||
#create a web_dwc2.py symlink if not already existing
|
#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
|
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!"
|
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py
|
||||||
|
ok_msg "Symlink created!"
|
||||||
fi
|
fi
|
||||||
}
|
#get Duet Web Control
|
||||||
|
|
||||||
dwc2_setup(){
|
|
||||||
#check dependencies
|
|
||||||
dep=(wget gzip tar curl)
|
|
||||||
dependency_check
|
|
||||||
#execute operation
|
|
||||||
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
|
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
|
||||||
cd $DWC2_DIR/web
|
cd $DWC2_DIR/web
|
||||||
status_msg "Downloading DWC2 Web UI ..."
|
status_msg "Downloading DWC2 Web UI ..."
|
||||||
wget -q $GET_DWC2_URL && ok_msg "Download complete!"
|
wget -q $GET_DWC2_URL
|
||||||
|
ok_msg "Download complete!"
|
||||||
status_msg "Unzipping archive ..."
|
status_msg "Unzipping archive ..."
|
||||||
unzip -q -o *.zip && for f_ in $(find . | grep '.gz');do gunzip -f ${f_};done && ok_msg "Done!"
|
unzip -q -o *.zip
|
||||||
status_msg "Writing version to file ..."
|
for f_ in $(find . | grep '.gz')
|
||||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version && ok_msg "Done!"
|
do
|
||||||
|
gunzip -f ${f_}
|
||||||
|
done
|
||||||
|
ok_msg "Done!"
|
||||||
|
status_msg "Writing DWC version to file ..."
|
||||||
|
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version
|
||||||
|
ok_msg "Done!"
|
||||||
status_msg "Do a little cleanup ..."
|
status_msg "Do a little cleanup ..."
|
||||||
rm -rf DuetWebControl-SD.zip && ok_msg "Done!"
|
rm -rf DuetWebControl-SD.zip
|
||||||
|
ok_msg "Done!"
|
||||||
ok_msg "DWC2 Web UI installed!"
|
ok_msg "DWC2 Web UI installed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,27 +189,31 @@ setup_printer_config_dwc2(){
|
|||||||
fi
|
fi
|
||||||
if [ "$SEL_DEF_CFG" = "true" ]; then
|
if [ "$SEL_DEF_CFG" = "true" ]; then
|
||||||
create_default_dwc2_printer_cfg
|
create_default_dwc2_printer_cfg
|
||||||
|
locate_printer_cfg
|
||||||
fi
|
fi
|
||||||
if [ "$SEL_CUS_CFG" = "true" ]; then
|
if [ "$SEL_CUS_CFG" = "true" ]; then
|
||||||
#get user input for custom config
|
#get user input for custom config
|
||||||
create_custom_dwc2_printer_cfg
|
create_custom_dwc2_printer_cfg
|
||||||
|
locate_printer_cfg
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
read_printer_cfg_dwc2(){
|
read_printer_cfg_dwc2(){
|
||||||
unset SC_ENTRY
|
unset SC_ENTRY
|
||||||
SC="#*# <---------------------- SAVE_CONFIG ---------------------->"
|
SC="#*# <---------------------- SAVE_CONFIG ---------------------->"
|
||||||
if [ ! $(grep '^\[virtual_sdcard\]$' ${HOME}/printer.cfg) ]; then
|
if [ ! $(grep '^\[virtual_sdcard\]$' $PRINTER_CFG) ]; then
|
||||||
VSD="false"
|
VSD="false"
|
||||||
fi
|
fi
|
||||||
if [ ! $(grep '^\[web_dwc2\]$' ${HOME}/printer.cfg) ]; then
|
if [ ! $(grep '^\[web_dwc2\]$' $PRINTER_CFG) ]; then
|
||||||
WEB_DWC2="false"
|
WEB_DWC2="false"
|
||||||
fi
|
fi
|
||||||
#check for a SAVE_CONFIG entry
|
#check for a SAVE_CONFIG entry
|
||||||
if [[ $(grep "$SC" ${HOME}/printer.cfg) ]]; then
|
if [[ $(grep "$SC" $PRINTER_CFG) ]]; then
|
||||||
SC_LINE=$(grep -n "$SC" ${HOME}/printer.cfg | cut -d ":" -f1)
|
SC_LINE=$(grep -n "$SC" $PRINTER_CFG | cut -d ":" -f1)
|
||||||
PRE_SC_LINE=$(expr $SC_LINE - 1)
|
PRE_SC_LINE=$(expr $SC_LINE - 1)
|
||||||
SC_ENTRY="true"
|
SC_ENTRY="true"
|
||||||
|
else
|
||||||
|
SC_ENTRY="false"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,30 +235,32 @@ write_printer_cfg_dwc2(){
|
|||||||
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
|
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
|
||||||
for entry in "${write_entries[@]}"
|
for entry in "${write_entries[@]}"
|
||||||
do
|
do
|
||||||
sed -i "$PRE_SC_LINE $entry" ${HOME}/printer.cfg
|
sed -i "$PRE_SC_LINE $entry" $PRINTER_CFG
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ "$SC_ENTRY" = "false" ]; then
|
if [ "$SC_ENTRY" = "false" ]; then
|
||||||
LINE_COUNT="$(wc -l < ${HOME}/printer.cfg)a"
|
LINE_COUNT="$(wc -l < $PRINTER_CFG)a"
|
||||||
for entry in "${write_entries[@]}"
|
for entry in "${write_entries[@]}"
|
||||||
do
|
do
|
||||||
sed -i "$LINE_COUNT $entry" ${HOME}/printer.cfg
|
sed -i "$LINE_COUNT $entry" $PRINTER_CFG
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
write_custom_printer_cfg_dwc2(){
|
write_custom_printer_cfg_dwc2(){
|
||||||
if [ "$CONFIRM_CUSTOM_CFG" = "true" ]; then
|
#create custom config
|
||||||
echo -e "$DWC2_CFG" >> ${HOME}/printer.cfg
|
if [ "$PRINTER_CFG_FOUND" = "false" ] && [ "$CONFIRM_CUSTOM_CFG" = "true" ]; then
|
||||||
|
touch $PRINTER_CFG
|
||||||
|
echo -e "$DWC2_CFG" >> $PRINTER_CFG
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
create_default_dwc2_printer_cfg(){
|
create_default_dwc2_printer_cfg(){
|
||||||
#create default config
|
#create default config
|
||||||
touch ${HOME}/printer.cfg
|
if [ "$PRINTER_CFG_FOUND" = "false" ] && [ "$SEL_CUS_CFG" = "true" ]; then
|
||||||
cat <<DEFAULT_DWC2_CFG >> ${HOME}/printer.cfg
|
touch $PRINTER_CFG
|
||||||
|
cat <<DEFAULT_DWC2_CFG >> $PRINTER_CFG
|
||||||
##########################
|
##########################
|
||||||
### CREATED WITH KIAUH ###
|
### CREATED WITH KIAUH ###
|
||||||
##########################
|
##########################
|
||||||
@@ -267,8 +280,8 @@ listen_adress: 0.0.0.0
|
|||||||
listen_port: 4750
|
listen_port: 4750
|
||||||
web_path: dwc2/web
|
web_path: dwc2/web
|
||||||
##########################
|
##########################
|
||||||
##########################
|
|
||||||
DEFAULT_DWC2_CFG
|
DEFAULT_DWC2_CFG
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
@@ -288,7 +301,6 @@ create_custom_dwc2_printer_cfg(){
|
|||||||
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
|
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
|
||||||
echo -e "${default}"
|
echo -e "${default}"
|
||||||
DWC2_CFG=$(cat <<DWC2
|
DWC2_CFG=$(cat <<DWC2
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
### CREATED WITH KIAUH ###
|
### CREATED WITH KIAUH ###
|
||||||
##########################
|
##########################
|
||||||
@@ -301,7 +313,6 @@ listen_adress: $LISTEN_ADRESS
|
|||||||
listen_port: $LISTEN_PORT
|
listen_port: $LISTEN_PORT
|
||||||
web_path: $WEB_PATH
|
web_path: $WEB_PATH
|
||||||
##########################
|
##########################
|
||||||
##########################
|
|
||||||
DWC2
|
DWC2
|
||||||
)
|
)
|
||||||
echo "The following lines will be written:"
|
echo "The following lines will be written:"
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
install_mainsail(){
|
install_mainsail(){
|
||||||
if [ "$INST_MAINSAIL" = "true" ]; then
|
if [ "$INST_MAINSAIL" = "true" ]; then
|
||||||
if [ -d $KLIPPER_DIR ]; then
|
disable_haproxy_lighttpd
|
||||||
disable_haproxy_lighttpd
|
unset SET_REVERSE_PROXY && SET_REVERSE_PROXY="true" #quick and dirty hack to make mainsail reverse proxy install, needs polish
|
||||||
unset SET_REVERSE_PROXY && SET_REVERSE_PROXY="true" #quick and dirty hack to make mainsail reverse proxy install, needs polish
|
create_reverse_proxy "mainsail"
|
||||||
create_reverse_proxy "mainsail"
|
mainsail_setup
|
||||||
mainsail_setup
|
test_nginx
|
||||||
test_nginx
|
ok_msg "Mainsail installation complete!"; echo
|
||||||
ok_msg "Mainsail installation complete!"; echo
|
|
||||||
else
|
|
||||||
ERROR_MSG=" Please install Klipper first!\n Skipping..."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,30 +10,31 @@ install_moonraker(){
|
|||||||
setup_moonraker_conf
|
setup_moonraker_conf
|
||||||
#execute customizations
|
#execute customizations
|
||||||
write_custom_trusted_clients
|
write_custom_trusted_clients
|
||||||
symlink_moonraker_log
|
symlinks_moonraker
|
||||||
disable_octoprint
|
disable_octoprint
|
||||||
install_mainsail
|
|
||||||
set_hostname
|
set_hostname
|
||||||
#after install actions
|
#after install actions
|
||||||
restart_moonraker
|
restart_moonraker
|
||||||
restart_klipper
|
restart_klipper
|
||||||
test_api
|
test_api
|
||||||
|
install_mainsail
|
||||||
}
|
}
|
||||||
|
|
||||||
system_check_moonraker(){
|
system_check_moonraker(){
|
||||||
status_msg "Initializing Moonraker installation ..."
|
status_msg "Initializing Moonraker installation ..."
|
||||||
#check for existing printer.cfg and for the location
|
#check for existing printer.cfg and for the location
|
||||||
if [ ! -e ${HOME}/printer.cfg ] && [ ! -e ${HOME}/klipper_config/printer.cfg ]; then
|
locate_printer_cfg
|
||||||
PRINTER_CFG_FOUND="false"
|
if [ ! -z $PRINTER_CFG ]; then
|
||||||
|
PRINTER_CFG_FOUND="true"
|
||||||
|
PRINTER_CFG_LOC=$PRINTER_CFG
|
||||||
else
|
else
|
||||||
if [ -f ${HOME}/printer.cfg ]; then
|
PRINTER_CFG_FOUND="false"
|
||||||
PRINTER_CFG_FOUND="true"
|
fi
|
||||||
PRINTER_CFG_LOC="${HOME}/printer.cfg"
|
#check for existing klippy.log symlink in /klipper_config
|
||||||
fi
|
if [ ! -e ${HOME}/klipper_config/klippy.log ]; then
|
||||||
if [ -f ${HOME}/klipper_config/printer.cfg ]; then
|
KLIPPY_SL_FOUND="false"
|
||||||
PRINTER_CFG_FOUND="true"
|
else
|
||||||
PRINTER_CFG_LOC="${HOME}/klipper_config/printer.cfg"
|
KLIPPY_SL_FOUND="true"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
#check for existing moonraker.log symlink in /klipper_config
|
#check for existing moonraker.log symlink in /klipper_config
|
||||||
if [ ! -e ${HOME}/klipper_config/moonraker.log ]; then
|
if [ ! -e ${HOME}/klipper_config/moonraker.log ]; then
|
||||||
@@ -86,7 +87,15 @@ get_user_selections_moonraker(){
|
|||||||
unset SEL_DEF_CFG
|
unset SEL_DEF_CFG
|
||||||
while true; do
|
while true; do
|
||||||
echo
|
echo
|
||||||
warn_msg "No printer.cfg found!"
|
top_border
|
||||||
|
echo -e "| ${red}WARNING! - No printer.cfg was found!${default} |"
|
||||||
|
hr
|
||||||
|
echo -e "| KIAUH can create a minimal printer.cfg with only the |"
|
||||||
|
echo -e "| necessary Mainsail config entries if you wish. |"
|
||||||
|
echo -e "| |"
|
||||||
|
echo -e "| Please be aware, that this option will ${red}NOT${default} create a |"
|
||||||
|
echo -e "| fully working printer.cfg for you! |"
|
||||||
|
bottom_border
|
||||||
read -p "${cyan}###### Create a default printer.cfg? (Y/n):${default} " yn
|
read -p "${cyan}###### Create a default printer.cfg? (Y/n):${default} " yn
|
||||||
case "$yn" in
|
case "$yn" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
@@ -100,6 +109,22 @@ get_user_selections_moonraker(){
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
#user selection for moonraker.log symlink
|
#user selection for moonraker.log symlink
|
||||||
|
if [ "$KLIPPY_SL_FOUND" = "false" ]; then
|
||||||
|
while true; do
|
||||||
|
echo
|
||||||
|
read -p "${cyan}###### Create klippy.log symlink? (Y/n):${default} " yn
|
||||||
|
case "$yn" in
|
||||||
|
Y|y|Yes|yes|"")
|
||||||
|
echo -e "###### > Yes"
|
||||||
|
SEL_KLIPPYLOG_SL="true";;
|
||||||
|
N|n|No|no)
|
||||||
|
echo -e "###### > No"
|
||||||
|
SEL_KLIPPYLOG_SL="false";;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
#user selection for moonraker.log symlink
|
||||||
if [ "$MOONRAKER_SL_FOUND" = "false" ]; then
|
if [ "$MOONRAKER_SL_FOUND" = "false" ]; then
|
||||||
while true; do
|
while true; do
|
||||||
echo
|
echo
|
||||||
@@ -142,10 +167,10 @@ get_user_selections_moonraker(){
|
|||||||
case "$yn" in
|
case "$yn" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
echo -e "###### > Yes"
|
echo -e "###### > Yes"
|
||||||
ADD_MAINSAIL_MACROS="true";;
|
ADD_MS_MCAROS="true";;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
echo -e "###### > No"
|
echo -e "###### > No"
|
||||||
ADD_MAINSAIL_MACROS="false";;
|
ADD_MS_MCAROS="false";;
|
||||||
esac
|
esac
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
@@ -211,17 +236,14 @@ check_for_folder_moonraker(){
|
|||||||
setup_printer_config_mainsail(){
|
setup_printer_config_mainsail(){
|
||||||
if [ "$PRINTER_CFG_FOUND" = "true" ]; then
|
if [ "$PRINTER_CFG_FOUND" = "true" ]; then
|
||||||
backup_printer_cfg
|
backup_printer_cfg
|
||||||
if [ "$PRINTER_CFG_LOC" != "${HOME}/klipper_config/printer.cfg" ]; then
|
#create a printer.cfg symlink to make it accessible
|
||||||
status_msg "Moving printer.cfg to ~/klipper_config ..."
|
#in the mainsail config editor if the printer.cfg is not
|
||||||
mv $PRINTER_CFG_LOC ${HOME}/klipper_config
|
#located in klipper_config by default
|
||||||
|
if [ "$PRINTER_CFG" != "${HOME}/klipper_config/printer.cfg" ] && [ ! -f ${HOME}/klipper_config/printer.cfg ]; then
|
||||||
|
status_msg "Create printer.cfg symlink ..."
|
||||||
|
ln -s $PRINTER_CFG ${HOME}/klipper_config
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
fi
|
fi
|
||||||
status_msg "Create symlink in home directory ..."
|
|
||||||
if [ -f ${HOME}/printer.cfg ]; then
|
|
||||||
mv ${HOME}/printer.cfg ${HOME}/printer_old.cfg
|
|
||||||
fi
|
|
||||||
ln -s ${HOME}/klipper_config/printer.cfg ${HOME}
|
|
||||||
ok_msg "Done!"
|
|
||||||
#check printer.cfg for necessary mainsail entries
|
#check printer.cfg for necessary mainsail entries
|
||||||
read_printer_cfg_mainsail
|
read_printer_cfg_mainsail
|
||||||
write_printer_cfg_mainsail
|
write_printer_cfg_mainsail
|
||||||
@@ -233,7 +255,7 @@ setup_printer_config_mainsail(){
|
|||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
fi
|
fi
|
||||||
#copy mainsail_macro.cfg
|
#copy mainsail_macro.cfg
|
||||||
if [ "$ADD_MAINSAIL_MACROS" = "true" ]; then
|
if [ "$ADD_MS_MCAROS" = "true" ]; then
|
||||||
status_msg "Create mainsail_macros.cfg ..."
|
status_msg "Create mainsail_macros.cfg ..."
|
||||||
if [ ! -f ${HOME}/klipper_config/mainsail_macros.cfg ]; then
|
if [ ! -f ${HOME}/klipper_config/mainsail_macros.cfg ]; then
|
||||||
cp ${HOME}/kiauh/resources/mainsail_macros.cfg ${HOME}/klipper_config
|
cp ${HOME}/kiauh/resources/mainsail_macros.cfg ${HOME}/klipper_config
|
||||||
@@ -246,26 +268,31 @@ setup_printer_config_mainsail(){
|
|||||||
|
|
||||||
read_printer_cfg_mainsail(){
|
read_printer_cfg_mainsail(){
|
||||||
SC="#*# <---------------------- SAVE_CONFIG ---------------------->"
|
SC="#*# <---------------------- SAVE_CONFIG ---------------------->"
|
||||||
if [ ! $(grep '^\[virtual_sdcard\]$' ${HOME}/klipper_config/printer.cfg) ]; then
|
if [ ! $(grep '^\[virtual_sdcard\]$' $PRINTER_CFG) ]; then
|
||||||
VSD="false"
|
VSD="false"
|
||||||
fi
|
fi
|
||||||
if [ ! $(grep '^\[pause_resume\]$' ${HOME}/klipper_config/printer.cfg) ]; then
|
if [ ! $(grep '^\[pause_resume\]$' $PRINTER_CFG) ]; then
|
||||||
PAUSE_RESUME="false"
|
PAUSE_RESUME="false"
|
||||||
fi
|
fi
|
||||||
if [ ! $(grep '^\[display_status\]$' ${HOME}/klipper_config/printer.cfg) ]; then
|
if [ ! $(grep '^\[display_status\]$' $PRINTER_CFG) ]; then
|
||||||
DISPLAY_STATUS="false"
|
DISPLAY_STATUS="false"
|
||||||
fi
|
fi
|
||||||
|
if [ ! "$(grep '^\[include klipper_config\/mainsail_macros\.cfg\]$' $PRINTER_CFG)" ]; then
|
||||||
|
MS_MACRO="false"
|
||||||
|
fi
|
||||||
#check for a SAVE_CONFIG entry
|
#check for a SAVE_CONFIG entry
|
||||||
if [[ $(grep "$SC" ${HOME}/klipper_config/printer.cfg) ]]; then
|
if [[ $(grep "$SC" $PRINTER_CFG) ]]; then
|
||||||
SC_LINE=$(grep -n "$SC" ${HOME}/klipper_config/printer.cfg | cut -d ":" -f1)
|
SC_LINE=$(grep -n "$SC" $PRINTER_CFG | cut -d ":" -f1)
|
||||||
PRE_SC_LINE=$(expr $SC_LINE - 1)
|
PRE_SC_LINE=$(expr $SC_LINE - 1)
|
||||||
SC_ENTRY="true"
|
SC_ENTRY="true"
|
||||||
|
else
|
||||||
|
SC_ENTRY="false"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
write_printer_cfg_mainsail(){
|
write_printer_cfg_mainsail(){
|
||||||
unset write_entries
|
unset write_entries
|
||||||
if [ "$ADD_MAINSAIL_MACROS" = "true" ]; then
|
if [ "$MS_MACRO" = "false" ] && [ "$ADD_MS_MCAROS" = "true" ]; then
|
||||||
write_entries+=("[include klipper_config/mainsail_macros.cfg]")
|
write_entries+=("[include klipper_config/mainsail_macros.cfg]")
|
||||||
fi
|
fi
|
||||||
if [ "$PAUSE_RESUME" = "false" ]; then
|
if [ "$PAUSE_RESUME" = "false" ]; then
|
||||||
@@ -287,14 +314,14 @@ write_printer_cfg_mainsail(){
|
|||||||
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
|
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
|
||||||
for entry in "${write_entries[@]}"
|
for entry in "${write_entries[@]}"
|
||||||
do
|
do
|
||||||
sed -i "$PRE_SC_LINE $entry" ${HOME}/klipper_config/printer.cfg
|
sed -i "$PRE_SC_LINE $entry" $PRINTER_CFG
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ "$SC_ENTRY" = "false" ]; then
|
if [ "$SC_ENTRY" = "false" ]; then
|
||||||
LINE_COUNT="$(wc -l < ${HOME}/klipper_config/printer.cfg)a"
|
LINE_COUNT="$(wc -l < $PRINTER_CFG)a"
|
||||||
for entry in "${write_entries[@]}"
|
for entry in "${write_entries[@]}"
|
||||||
do
|
do
|
||||||
sed -i "$LINE_COUNT $entry" ${HOME}/klipper_config/printer.cfg
|
sed -i "$LINE_COUNT $entry" $PRINTER_CFG
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
@@ -358,7 +385,7 @@ write_default_trusted_clients(){
|
|||||||
#write the ip range in the first line below "trusted clients"
|
#write the ip range in the first line below "trusted clients"
|
||||||
#example: 192.168.1.0/24
|
#example: 192.168.1.0/24
|
||||||
sed -i "/trusted_clients\:/a \ \ \ \ $DEFAULT_IP_RANGE" ${HOME}/moonraker.conf
|
sed -i "/trusted_clients\:/a \ \ \ \ $DEFAULT_IP_RANGE" ${HOME}/moonraker.conf
|
||||||
ok_msg "IP range of ${cyan}$DEFAULT_IP_RANGE${default} written to moonraker.conf!"
|
ok_msg "IP range of ● $DEFAULT_IP_RANGE written to moonraker.conf!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
@@ -431,11 +458,17 @@ write_custom_trusted_clients(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink_moonraker_log(){
|
symlinks_moonraker(){
|
||||||
#create a moonraker.log symlink in klipper_config-dir just for convenience
|
#create a klippy.log/moonraker.log symlink in
|
||||||
if [ "$SEL_MRLOG_SL" = "true" ]; then
|
#klipper_config-dir just for convenience
|
||||||
|
if [ "$SEL_KLIPPYLOG_SL" = "true" ] && [ ! -e ${HOME}/klipper_config/klippy.log ]; then
|
||||||
|
status_msg "Creating klippy.log symlink ..."
|
||||||
|
ln -s /tmp/klippy.log ${HOME}/klipper_config
|
||||||
|
ok_msg "Symlink created!"
|
||||||
|
fi
|
||||||
|
if [ "$SEL_MRLOG_SL" = "true" ] && [ ! -e ${HOME}/klipper_config/moonraker.log ]; then
|
||||||
status_msg "Creating moonraker.log symlink ..."
|
status_msg "Creating moonraker.log symlink ..."
|
||||||
ln -s /tmp/moonraker.log ${HOME}/klipper_config/moonraker.log
|
ln -s /tmp/moonraker.log ${HOME}/klipper_config
|
||||||
ok_msg "Symlink created!"
|
ok_msg "Symlink created!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -454,4 +487,4 @@ test_api(){
|
|||||||
else
|
else
|
||||||
echo; warn_msg "Klipper API not working correctly!"; echo
|
echo; warn_msg "Klipper API not working correctly!"; echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ remove_moonraker(){
|
|||||||
${HOME}/moonraker.conf
|
${HOME}/moonraker.conf
|
||||||
${HOME}/moonraker.log
|
${HOME}/moonraker.log
|
||||||
${HOME}/klipper_config/moonraker.log
|
${HOME}/klipper_config/moonraker.log
|
||||||
|
${HOME}/klipper_config/klippy.log
|
||||||
${HOME}/.klippy_api_key
|
${HOME}/.klippy_api_key
|
||||||
${HOME}/.moonraker_api_key
|
${HOME}/.moonraker_api_key
|
||||||
)
|
)
|
||||||
@@ -89,17 +90,10 @@ remove_moonraker(){
|
|||||||
status_msg "Removing moonraker.conf ..."
|
status_msg "Removing moonraker.conf ..."
|
||||||
rm -rf ${HOME}/moonraker.conf && ok_msg "File removed!"
|
rm -rf ${HOME}/moonraker.conf && ok_msg "File removed!"
|
||||||
fi
|
fi
|
||||||
#remove printer.cfg symlink, copy printer.cfg back into home dir
|
|
||||||
if [ -L ${HOME}/printer.cfg ]; then
|
|
||||||
status_msg "Removing printer.cfg symlink ..."
|
|
||||||
rm -rf ${HOME}/printer.cfg && ok_msg "Symlink removed!"
|
|
||||||
status_msg "Copy printer.cfg back into '${HOME}' ..."
|
|
||||||
cp ${HOME}/klipper_config/printer.cfg ${HOME} && ok_msg "File copied!"
|
|
||||||
fi
|
|
||||||
#remove moonraker.log and symlink
|
#remove moonraker.log and symlink
|
||||||
if [[ -L ${HOME}/moonraker.log || -L ${HOME}/klipper_config/moonraker.log || -e /tmp/moonraker.log ]]; then
|
if [[ -L ${HOME}/moonraker.log || -L ${HOME}/klipper_config/moonraker.log || -L ${HOME}/klipper_config/klippy.log || -e /tmp/moonraker.log ]]; then
|
||||||
status_msg "Removing moonraker.log and Symlink ..."
|
status_msg "Removing Logs and Symlinks ..."
|
||||||
rm -rf ${HOME}/moonraker.log ${HOME}/klipper_config/moonraker.log /tmp/moonraker.log
|
rm -rf ${HOME}/moonraker.log ${HOME}/klipper_config/moonraker.log ${HOME}/klipper_config/klippy.log /tmp/moonraker.log
|
||||||
ok_msg "Files removed!"
|
ok_msg "Files removed!"
|
||||||
fi
|
fi
|
||||||
#remove legacy api key
|
#remove legacy api key
|
||||||
|
|||||||
Reference in New Issue
Block a user