diff --git a/kiauh.sh b/kiauh.sh index 73604b1..efa91d3 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -17,19 +17,14 @@ for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . $script; done ### set important directories #klipper KLIPPER_DIR=${HOME}/klipper -KLIPPY_ENV_DIR=${HOME}/klippy-env -KLIPPER_SERVICE1=/etc/init.d/klipper -KLIPPER_SERVICE2=/etc/default/klipper -KLIPPER_SERVICE3=/etc/systemd/system/klipper.service +KLIPPY_ENV=${HOME}/klippy-env #nginx NGINX_SA=/etc/nginx/sites-available NGINX_SE=/etc/nginx/sites-enabled NGINX_CONFD=/etc/nginx/conf.d #moonraker MOONRAKER_DIR=${HOME}/moonraker -MOONRAKER_ENV_DIR=${HOME}/moonraker-env -MOONRAKER_SERVICE1=/etc/init.d/moonraker -MOONRAKER_SERVICE2=/etc/default/moonraker +MOONRAKER_ENV=${HOME}/moonraker-env #mainsail MAINSAIL_DIR=${HOME}/mainsail #fluidd @@ -75,7 +70,7 @@ title_msg(){ echo -e "${cyan}$1${default}" } get_date(){ - current_date=$(date +"%Y-%m-%d_%H-%M") + current_date=$(date +"%Y%m%d_%H%M") } print_unkown_cmd(){ ERROR_MSG="Invalid command!" diff --git a/scripts/backup.sh b/scripts/backup.sh index f0a55b1..ac69aca 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -16,6 +16,19 @@ backup_printer_cfg(){ fi } +backup_klipper_config_dir(){ + source_kiauh_ini + check_for_backup_dir + if [ -d "$klipper_cfg_loc" ]; then + get_date + status_msg "Create backup of the Klipper config directory ..." + config_folder_name="$(echo "$klipper_cfg_loc" | rev | cut -d"/" -f1 | rev)" + cp -r "$klipper_cfg_loc" "$BACKUP_DIR/$config_folder_name.$current_date.backup" && ok_msg "Backup complete!" + else + ok_msg "No config directory found! Skipping backup ..." + fi +} + backup_moonraker_conf(){ check_for_backup_dir if [ -f ${HOME}/moonraker.conf ]; then @@ -28,7 +41,7 @@ backup_moonraker_conf(){ } read_bb4u_stat(){ - source_ini + source_kiauh_ini if [ ! "$backup_before_update" = "true" ]; then BB4U_STATUS="${green}[Enable]${default} backups before updating " else @@ -37,7 +50,7 @@ read_bb4u_stat(){ } toggle_backups(){ - source_ini + source_kiauh_ini if [ "$backup_before_update" = "true" ]; then sed -i '/backup_before_update=/s/true/false/' $INI_FILE BB4U_STATUS="${green}[Enable]${default} backups before updating " @@ -51,7 +64,7 @@ toggle_backups(){ } bb4u(){ - source_ini + source_kiauh_ini if [ "$backup_before_update" = "true" ]; then backup_$1 fi diff --git a/scripts/ui/backup_menu.sh b/scripts/ui/backup_menu.sh index 6c7d1e3..ef6c3d2 100755 --- a/scripts/ui/backup_menu.sh +++ b/scripts/ui/backup_menu.sh @@ -4,21 +4,14 @@ backup_ui(){ hr echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | " hr - echo -e "| Firmware: | " - echo -e "| 1) [Klipper] | " - echo -e "| | " - echo -e "| Klipper API: | " - echo -e "| 2) [Moonraker] | " - echo -e "| | " - echo -e "| Webinterface: | " - echo -e "| 3) [Mainsail] | " - echo -e "| 4) [Fluidd] | " - echo -e "| 5) [DWC2 Web UI] | " - echo -e "| 6) [OctoPrint] | " - echo -e "| | " - echo -e "| HDMI Screen: | " - echo -e "| 7) [KlipperScreen] | " - echo -e "| | " + echo -e "| Configuration folder: | Webinterface: | " + echo -e "| 0) [Klipper configs] | 3) [Mainsail] | " + echo -e "| | 4) [Fluidd] | " + echo -e "| Firmware: | 5) [DWC2 Web UI] | " + echo -e "| 1) [Klipper] | 6) [OctoPrint] | " + echo -e "| | | " + echo -e "| Klipper API: | HDMI Screen: | " + echo -e "| 2) [Moonraker] | 7) [KlipperScreen] | " quit_footer } @@ -29,6 +22,12 @@ backup_menu(){ while true; do read -p "${cyan}Perform action:${default} " action; echo case "$action" in + 0) + clear + print_header + backup_klipper_config_dir + print_msg && clear_msg + backup_ui;; 1) clear print_header