mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
fix: broken set_klipper_cfg_path function (#163)
This commit is contained in:
@@ -89,28 +89,29 @@ set_klipper_cfg_path(){
|
|||||||
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
|
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
|
||||||
if [ ! -d "$new_klipper_cfg_loc" ]; then
|
if [ ! -d "$new_klipper_cfg_loc" ]; then
|
||||||
status_msg "Copy config files to '$new_klipper_cfg_loc' ..."
|
status_msg "Copy config files to '$new_klipper_cfg_loc' ..."
|
||||||
mkdir -p $new_klipper_cfg_loc
|
mkdir -p "$new_klipper_cfg_loc"
|
||||||
cd $old_klipper_cfg_loc
|
cd $old_klipper_cfg_loc
|
||||||
cp -r -v ./* $new_klipper_cfg_loc
|
cp -r -v ./* "$new_klipper_cfg_loc"
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])+[0-9]*.service")
|
||||||
### handle single klipper instance service file
|
### handle single klipper instance service file
|
||||||
if [ -f $SYSTEMDDIR/klipper.service ]; then
|
if [ -f $SYSTEMDDIR/klipper.service ]; then
|
||||||
status_msg "Configuring Klipper for new path ..."
|
status_msg "Configuring Klipper for new path ..."
|
||||||
sudo sed -i -r "/ExecStart=/ s| (.+)\/printer.cfg| $new_klipper_cfg_loc/printer.cfg|" $SYSTEMDDIR/klipper.service
|
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer.cfg|klippy.py $new_klipper_cfg_loc/printer.cfg|" $SYSTEMDDIR/klipper.service
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
elif [ -n "$SERVICE_FILES" ]; then
|
||||||
### handle multi klipper instance service file
|
### handle multi klipper instance service file
|
||||||
if ls $SYSTEMDDIR/klipper-*.service 2>/dev/null 1>&2; then
|
|
||||||
status_msg "Configuring Klipper for new path ..."
|
status_msg "Configuring Klipper for new path ..."
|
||||||
for service in $(find $SYSTEMDDIR/klipper-*.service); do
|
for service in $SERVICE_FILES; do
|
||||||
sudo sed -i -r "/ExecStart=/ s| (.+)\/printer_| $new_klipper_cfg_loc/printer_|" $service
|
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer_|klippy.py $new_klipper_cfg_loc/printer_|" "$service"
|
||||||
done
|
done
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])+[0-9]*.service")
|
||||||
### handle single moonraker instance service and moonraker.conf file
|
### handle single moonraker instance service and moonraker.conf file
|
||||||
if [ -f $SYSTEMDDIR/moonraker.service ]; then
|
if [ -f $SYSTEMDDIR/moonraker.service ]; then
|
||||||
status_msg "Configuring Moonraker for new path ..."
|
status_msg "Configuring Moonraker for new path ..."
|
||||||
@@ -119,17 +120,17 @@ set_klipper_cfg_path(){
|
|||||||
### replace old file path with new one in moonraker.conf
|
### replace old file path with new one in moonraker.conf
|
||||||
sed -i -r "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
|
sed -i -r "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
elif [ -n "$SERVICE_FILES" ]; then
|
||||||
### handle multi moonraker instance service file
|
### handle multi moonraker instance service file
|
||||||
if ls $SYSTEMDDIR/moonraker-*.service 2>/dev/null 1>&2; then
|
|
||||||
status_msg "Configuring Moonraker for new path ..."
|
status_msg "Configuring Moonraker for new path ..."
|
||||||
for service in $(find $SYSTEMDDIR/moonraker-*.service); do
|
for service in $SERVICE_FILES; do
|
||||||
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/printer_|-c $new_klipper_cfg_loc/printer_|" $service
|
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/printer_|-c $new_klipper_cfg_loc/printer_|" "$service"
|
||||||
done
|
done
|
||||||
|
MR_CONFS=$(find "$new_klipper_cfg_loc" -regextype posix-extended -regex "$new_klipper_cfg_loc/printer_[1-9]+/moonraker.conf")
|
||||||
### replace old file path with new one in moonraker.conf
|
### replace old file path with new one in moonraker.conf
|
||||||
for moonraker_conf in $(find $new_klipper_cfg_loc/printer_*/moonraker.conf); do
|
for moonraker_conf in $MR_CONFS; do
|
||||||
loc=$(echo "$moonraker_conf" | rev | cut -d"/" -f2- | rev)
|
loc=$(echo "$moonraker_conf" | rev | cut -d"/" -f2- | rev)
|
||||||
sed -i -r "/config_path:/ s|config_path:.*|config_path: $loc|" $moonraker_conf
|
sed -i -r "/config_path:/ s|config_path:.*|config_path: $loc|" "$moonraker_conf"
|
||||||
done
|
done
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user