From df4fe6822807f54a69d5ea30ac5085869cd19e80 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Wed, 10 Aug 2022 12:12:04 +0200 Subject: [PATCH] Fix: read question (arch) --- etc/upd/upd.conf | 1 + usr/local/bin/upd | 3 ++- var/lib/upd/scripts/check | 34 +++++++++-------------- var/lib/upd/scripts/clean | 52 ++++++++++++++++++++++++++++++++++++ var/lib/upd/scripts/updater | 6 +++-- var/lib/upd/scripts/upgrader | 36 ++----------------------- 6 files changed, 74 insertions(+), 58 deletions(-) create mode 100644 var/lib/upd/scripts/clean diff --git a/etc/upd/upd.conf b/etc/upd/upd.conf index e46feab..414fb3d 100644 --- a/etc/upd/upd.conf +++ b/etc/upd/upd.conf @@ -15,6 +15,7 @@ upd_file_check_aur="$upd_dir_home/check_aur" # Script upd_script_check="/var/lib/upd/scripts/check" +upd_script_clean="/var/lib/upd/scripts/clean" upd_script_help="/var/lib/upd/scripts/help" upd_script_tools="/var/lib/upd/scripts/tools" upd_script_updater="/var/lib/upd/scripts/updater" diff --git a/usr/local/bin/upd b/usr/local/bin/upd index 79d8337..583905b 100755 --- a/usr/local/bin/upd +++ b/usr/local/bin/upd @@ -1,5 +1,5 @@ #!/bin/bash -# version: 0.1.4 +# version: 0.1.5 # file: upd # Folder: /usr/local/bin # By echolib @@ -83,6 +83,7 @@ if__file "/etc/upd/upd.conf" source if__file "$upd_script_tools" source if__file "$upd_script_updater" source if__file "$upd_script_check" source +if__file "$upd_script_clean" source if__file "$upd_script_upgrader" source if__file "$upd_script_help" source diff --git a/var/lib/upd/scripts/check b/var/lib/upd/scripts/check index cc28777..b3a5f4c 100644 --- a/var/lib/upd/scripts/check +++ b/var/lib/upd/scripts/check @@ -17,20 +17,6 @@ esac } -#====================================================================== -# Cleaning System -#====================================================================== -clean__OPTIONS() { -upd__sudoroot -clear -echo "# Cleaning System..." -case "$arch" in - pacman) upd__clean_arch ;; - apt) upd__clean_deb ;; -esac -} - - #====================================================================== # Check for updates from ArchLinux #====================================================================== @@ -81,15 +67,17 @@ upd__prepare_show upd__check_reboot() { upd__reboot_set() { - upd_reboot="$Pp_Grey ${C_Red}Reboot$NC required" + upd_reboot="$Pp_Grey ${C_Red}Reboot$NC required ; $upd_uname > $upd_vmlin" upd_inf="$I_Red" } # if erboot case "$arch" in pacman) - [[ `uname -r` == `file /boot/vmlinuz-linux | awk '{print $9}'` ]] \ - || upd__reboot_set + upd_uname=`uname -r` + upd_vmlin=`file /boot/vmlinuz-linux | awk '{print $9}'` + [[ "$upd_uname" != "$upd_vmlin" ]] \ + && upd__reboot_set ;; apt) @@ -99,10 +87,14 @@ case "$arch" in esac # Reboot message only: if called from option -cr -if [[ $upd_cr ]] && [[ $upd_reboot ]];then - echo -e "$upd_reboot" - exit 137 -fi +[[ $upd_cr ]] || exit +! [[ $upd_reboot ]] \ + && echo "# No need to reboot" \ + && exit + +echo -e "$upd_reboot" +exit 137 + } diff --git a/var/lib/upd/scripts/clean b/var/lib/upd/scripts/clean new file mode 100644 index 0000000..9092de3 --- /dev/null +++ b/var/lib/upd/scripts/clean @@ -0,0 +1,52 @@ +#!/bin/bash +# file: clean +# Folder: /var/lib/upd/scripts +# By echolib +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +# Cleaning System +#====================================================================== +clean__OPTIONS() { +upd__sudoroot +clear +echo "# Cleaning System..." +case "$arch" in + pacman) upd__clean_arch ;; + apt) upd__clean_deb ;; +esac +} + + +#====================================================================== +# Cleaing commons +#====================================================================== +upd__clean_commons() { +sudo journalctl --vacuum-time=3d +echo +[[ -d "~/.cache/" ]] \ + && sudo du -sh ~/.cache/ \ + && rm -rf ~/.cache/* \ + && echo +} + + +#====================================================================== +# Cleaing arch +#====================================================================== +upd__clean_arch() { +upd__clean_commons +sudo pacman -Sc +sudo pacman -Rns $(pacman -Qtdq) +} + + +#====================================================================== +# Cleaing deb +#====================================================================== +upd__clean_deb() { +upd__clean_commons +sudo apt autoremovee +} + diff --git a/var/lib/upd/scripts/updater b/var/lib/upd/scripts/updater index 96a9bf5..91b8739 100644 --- a/var/lib/upd/scripts/updater +++ b/var/lib/upd/scripts/updater @@ -52,8 +52,10 @@ tar -xzf "${app_name}-main.tar.gz" cd "${app_name}-main" cp -f "usr/local/bin/$app_name" "/usr/local/bin/$app_name" -rsync -a --delete "var/lib/$app_name/" "/var/lib/$app_name/" -rsync -a --delete "etc/$app_name/" "/etc/$app_name/" +rsync -a --delete --exclude ".*" \ + "var/lib/$app_name/" "/var/lib/$app_name/" +rsync -a --delete --exclude ".*" \ + "etc/$app_name/" "/etc/$app_name/" rm -rf "/tmp/${app_name}-main" rm -f "/tmp/${app_name}-main.tar.gz" diff --git a/var/lib/upd/scripts/upgrader b/var/lib/upd/scripts/upgrader index 9b99c7a..1ae484b 100644 --- a/var/lib/upd/scripts/upgrader +++ b/var/lib/upd/scripts/upgrader @@ -104,10 +104,10 @@ upg_rep=$? if (( $upg_rep != 0 ));then printf '\n%s\n%s\n%s\n\n' \ "! An error has been detected" \ - "- Try to repair, first (R)" \ + "- Try to repair, first (R)" \ "- Try to manually update (U)" -read ": What to do (R|U|*) ? " upg_try +read -rp ": What to do (R|U|*) ? " upg_try case "$upg_try" in R) upd --arch-repair;exit ;; @@ -188,35 +188,3 @@ sudo pacman -Scc sysup="system" upg__main } - - -#====================================================================== -# Cleaing commons -#====================================================================== -upd__clean_commons() { -sudo journalctl --vacuum-time=3d -echo -[[ -d "~/.cache/" ]] \ - && sudo du -sh ~/.cache/ \ - && rm -rf ~/.cache/* \ - && echo -} - - -#====================================================================== -# Cleaing arch -#====================================================================== -upd__clean_arch() { -upd__clean_commons -sudo pacman -Sc -sudo pacman -Rns $(pacman -Qtdq) -} - - -#====================================================================== -# Cleaing deb -#====================================================================== -upd__clean_deb() { -upd__clean_commons -sudo apt autoremovee -}