diff --git a/scripts/backup.sh b/scripts/backup.sh index d28445d..c329534 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -1,8 +1,12 @@ -backup_printer_cfg(){ +check_for_backup_dir(){ if [ ! -d $BACKUP_DIR ]; then status_msg "Create backup directory ..." mkdir -p $BACKUP_DIR && ok_msg "Directory created!" fi +} + +backup_printer_cfg(){ + check_for_backup_dir if [ -f $PRINTER_CFG ]; then get_date status_msg "Create backup of printer.cfg ..." @@ -35,42 +39,64 @@ toggle_backups(){ fi } -bb4u_klipper(){ +bb4u(){ source_ini - if [ -d $KLIPPER_DIR ] && [ "$backup_before_update" = "true" ]; then - get_date + if [ "$backup_before_update" = "true" ]; then + backup_$1 + fi +} + +backup_klipper(){ + if [ -d $KLIPPER_DIR ] && [ -d $KLIPPY_ENV_DIR ]; then status_msg "Creating Klipper backup ..." + check_for_backup_dir + get_date + status_msg "Timestamp: $current_date" mkdir -p $BACKUP_DIR/klipper-backups/"$current_date" - cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ && ok_msg "Backup complete!" + cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ + ok_msg "Backup complete!" + else + ERROR_MSG=" Can't backup klipper and/or klipper-env directory! Not found!" fi } -bb4u_dwc2fk(){ - source_ini - if [ -d $DWC2FK_DIR ] && [ "$backup_before_update" = "true" ]; then - get_date - status_msg "Creating DWC2-for-Klipper backup ..." - mkdir -p $BACKUP_DIR/dwc2-for-klipper-backups/"$current_date" - cp -r $DWC2FK_DIR $_ && ok_msg "Backup complete!" - fi -} - -bb4u_dwc2(){ - source_ini - if [ -d $DWC2_DIR ] && [ "$backup_before_update" = "true" ]; then - get_date +backup_dwc2(){ + if [ -d $DWC2FK_DIR ] && [ -d $DWC2_DIR ]; then status_msg "Creating DWC2 Web UI backup ..." + check_for_backup_dir + get_date + status_msg "Timestamp: $current_date" mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date" - cp -r $DWC2_DIR $_ && ok_msg "Backup complete!" + cp -r $DWC2FK_DIR $_ && $DWC2_DIR $_ + ok_msg "Backup complete!" + else + ERROR_MSG=" Can't backup dwc2-for-klipper and/or dwc2 directory!\n Not found!" fi } -bb4u_mainsail(){ - source_ini - if [ -d $MAINSAIL_DIR ] && [ "$backup_before_update" = "true" ]; then - get_date +backup_mainsail(){ + if [ -d $MAINSAIL_DIR ]; then status_msg "Creating Mainsail backup ..." + check_for_backup_dir + get_date + status_msg "Timestamp: $current_date" mkdir -p $BACKUP_DIR/mainsail-backups/"$current_date" cp -r $MAINSAIL_DIR $_ && ok_msg "Backup complete!" + else + ERROR_MSG=" Can't backup mainsail directory! Not found!" + fi +} + +backup_octoprint(){ + if [ -d $OCTOPRINT_DIR ] && [ -d $OCTOPRINT_CFG_DIR ]; then + status_msg "Creating OctoPrint backup ..." + check_for_backup_dir + get_date + status_msg "Timestamp: $current_date" + mkdir -p $BACKUP_DIR/octoprint-backups/"$current_date" + cp -r $OCTOPRINT_DIR $_ && cp -r $OCTOPRINT_CFG_DIR $_ + ok_msg "Backup complete!" + else + ERROR_MSG=" Can't backup OctoPrint and/or .octoprint directory!\n Not found!" fi } \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index 73f92ff..2eefde1 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -10,7 +10,7 @@ update_check(){ update_klipper(){ stop_klipper - bb4u_klipper + bb4u "klipper" if [ ! -d $KLIPPER_DIR ]; then cd ${HOME} && git clone $KLIPPER_REPO else @@ -33,7 +33,7 @@ update_klipper(){ update_dwc2fk(){ stop_klipper - bb4u_dwc2fk + bb4u "dwc2" if [ ! -d $DWC2FK_DIR ]; then cd ${HOME} && git clone $DWC2FK_REPO else @@ -48,7 +48,7 @@ update_dwc2fk(){ } update_dwc2(){ - bb4u_dwc2 + bb4u "dwc2" #check dependencies dep=(wget gzip tar curl) dep_check @@ -70,7 +70,7 @@ update_dwc2(){ update_mainsail(){ stop_klipper - bb4u_mainsail + bb4u "mainsail" status_msg "Updating Mainsail ..." install_mainsail start_klipper