feat: klipper config backup function

This commit is contained in:
th33xitus
2021-01-07 15:24:25 +01:00
parent a44ae4c2b9
commit 61dfab5683
3 changed files with 33 additions and 26 deletions

View File

@@ -17,19 +17,14 @@ for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . $script; done
### set important directories ### set important directories
#klipper #klipper
KLIPPER_DIR=${HOME}/klipper KLIPPER_DIR=${HOME}/klipper
KLIPPY_ENV_DIR=${HOME}/klippy-env KLIPPY_ENV=${HOME}/klippy-env
KLIPPER_SERVICE1=/etc/init.d/klipper
KLIPPER_SERVICE2=/etc/default/klipper
KLIPPER_SERVICE3=/etc/systemd/system/klipper.service
#nginx #nginx
NGINX_SA=/etc/nginx/sites-available NGINX_SA=/etc/nginx/sites-available
NGINX_SE=/etc/nginx/sites-enabled NGINX_SE=/etc/nginx/sites-enabled
NGINX_CONFD=/etc/nginx/conf.d NGINX_CONFD=/etc/nginx/conf.d
#moonraker #moonraker
MOONRAKER_DIR=${HOME}/moonraker MOONRAKER_DIR=${HOME}/moonraker
MOONRAKER_ENV_DIR=${HOME}/moonraker-env MOONRAKER_ENV=${HOME}/moonraker-env
MOONRAKER_SERVICE1=/etc/init.d/moonraker
MOONRAKER_SERVICE2=/etc/default/moonraker
#mainsail #mainsail
MAINSAIL_DIR=${HOME}/mainsail MAINSAIL_DIR=${HOME}/mainsail
#fluidd #fluidd
@@ -75,7 +70,7 @@ title_msg(){
echo -e "${cyan}$1${default}" echo -e "${cyan}$1${default}"
} }
get_date(){ get_date(){
current_date=$(date +"%Y-%m-%d_%H-%M") current_date=$(date +"%Y%m%d_%H%M")
} }
print_unkown_cmd(){ print_unkown_cmd(){
ERROR_MSG="Invalid command!" ERROR_MSG="Invalid command!"

View File

@@ -16,6 +16,19 @@ backup_printer_cfg(){
fi 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(){ backup_moonraker_conf(){
check_for_backup_dir check_for_backup_dir
if [ -f ${HOME}/moonraker.conf ]; then if [ -f ${HOME}/moonraker.conf ]; then
@@ -28,7 +41,7 @@ backup_moonraker_conf(){
} }
read_bb4u_stat(){ read_bb4u_stat(){
source_ini source_kiauh_ini
if [ ! "$backup_before_update" = "true" ]; then if [ ! "$backup_before_update" = "true" ]; then
BB4U_STATUS="${green}[Enable]${default} backups before updating " BB4U_STATUS="${green}[Enable]${default} backups before updating "
else else
@@ -37,7 +50,7 @@ read_bb4u_stat(){
} }
toggle_backups(){ toggle_backups(){
source_ini source_kiauh_ini
if [ "$backup_before_update" = "true" ]; then if [ "$backup_before_update" = "true" ]; then
sed -i '/backup_before_update=/s/true/false/' $INI_FILE sed -i '/backup_before_update=/s/true/false/' $INI_FILE
BB4U_STATUS="${green}[Enable]${default} backups before updating " BB4U_STATUS="${green}[Enable]${default} backups before updating "
@@ -51,7 +64,7 @@ toggle_backups(){
} }
bb4u(){ bb4u(){
source_ini source_kiauh_ini
if [ "$backup_before_update" = "true" ]; then if [ "$backup_before_update" = "true" ]; then
backup_$1 backup_$1
fi fi

View File

@@ -4,21 +4,14 @@ backup_ui(){
hr hr
echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | " echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | "
hr hr
echo -e "| Firmware: | " echo -e "| Configuration folder: | Webinterface: | "
echo -e "| 1) [Klipper] | " echo -e "| 0) [Klipper configs] | 3) [Mainsail] | "
echo -e "| | " echo -e "| | 4) [Fluidd] | "
echo -e "| Klipper API: | " echo -e "| Firmware: | 5) [DWC2 Web UI] | "
echo -e "| 2) [Moonraker] | " echo -e "| 1) [Klipper] | 6) [OctoPrint] | "
echo -e "| | " echo -e "| | | "
echo -e "| Webinterface: | " echo -e "| Klipper API: | HDMI Screen: | "
echo -e "| 3) [Mainsail] | " echo -e "| 2) [Moonraker] | 7) [KlipperScreen] | "
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 "| | "
quit_footer quit_footer
} }
@@ -29,6 +22,12 @@ backup_menu(){
while true; do while true; do
read -p "${cyan}Perform action:${default} " action; echo read -p "${cyan}Perform action:${default} " action; echo
case "$action" in case "$action" in
0)
clear
print_header
backup_klipper_config_dir
print_msg && clear_msg
backup_ui;;
1) 1)
clear clear
print_header print_header