From 720cfd75b2fd0758446594c479f6b15030b06e46 Mon Sep 17 00:00:00 2001 From: velvettear Date: Mon, 28 Oct 2024 13:57:14 +0100 Subject: [PATCH 1/5] fix script to be posix compliant --- scripts/update/update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update/update.sh b/scripts/update/update.sh index a0c4d81..d3eeff5 100755 --- a/scripts/update/update.sh +++ b/scripts/update/update.sh @@ -8,16 +8,16 @@ distro="$(grep "^ID" /etc/*release | cut -d "=" -f2)" script="$(dirname $(realpath $0))/$distro.sh" # check if update script exists -[[ ! -x "$script" ]] && printf "error: update script '"$script"' does not exist or is not executable!\n" >&2 && exit 1 +[ ! -x "$script" ] && printf "error: update script '"$script"' does not exist or is not executable!\n" >&2 && exit 1 args="" for arg in "$@"; do - [[ -n "$args" ]] && args="$args " + [ -n "$args" ] && args="$args " args="$args$arg" done # execute update script -if [[ "$EUID" == "0" ]]; then +if [ "$(id -u)" -eq 0 ]; then "$script" $args else sudo "$script" $args From 9d912f5fee92e40276bca1349ef8a224c0e2fd32 Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 5 Nov 2024 15:43:50 +0100 Subject: [PATCH 2/5] fix update script for archlinux --- scripts/update/arch.sh | 3 +++ scripts/update/update.sh | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/update/arch.sh b/scripts/update/arch.sh index 9bf229f..6546d6e 100755 --- a/scripts/update/arch.sh +++ b/scripts/update/arch.sh @@ -25,6 +25,9 @@ for arg in "$@"; do esac done +# sudo +sudo id -u 2&> /dev/null + printf "${BOLD}${YELLOW}>> starting system update...${DEFAULT}\n" # upgrade installed packages diff --git a/scripts/update/update.sh b/scripts/update/update.sh index d3eeff5..e1b8f58 100755 --- a/scripts/update/update.sh +++ b/scripts/update/update.sh @@ -17,8 +17,11 @@ for arg in "$@"; do done # execute update script -if [ "$(id -u)" -eq 0 ]; then - "$script" $args +#if [ "$distro" == "arch" ]; then +# "$script" $args +if [ "$(id -u)" -eq 0 ] || [ "$distro" == "arch" ]; then +#elif [ "$(id -u)" -eq 0 ]; then + "$script" $args else sudo "$script" $args fi From 9ceae1e7f17688eb4be234cfeed5164dc65db83c Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 5 Nov 2024 15:44:12 +0100 Subject: [PATCH 3/5] modify script --- scripts/scan/batch-scan.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scan/batch-scan.sh b/scripts/scan/batch-scan.sh index 68871c1..e80daff 100755 --- a/scripts/scan/batch-scan.sh +++ b/scripts/scan/batch-scan.sh @@ -34,6 +34,6 @@ while true; do continue fi printf "> #"$counter": scanning to '"$file"' finished!\n" - postprocess "$file" "$directory" "$counter" + #postprocess "$file" "$directory" "$counter" ((counter++)) done From 4c0fd1c1039a33445318355351da09814c3c3fbd Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 5 Nov 2024 16:12:57 +0100 Subject: [PATCH 4/5] fix alpine update script to use shared cache --- scripts/update/alpine.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/update/alpine.sh b/scripts/update/alpine.sh index 01e1855..02ff4a4 100755 --- a/scripts/update/alpine.sh +++ b/scripts/update/alpine.sh @@ -19,7 +19,7 @@ for arg in "$@"; do noconfirm="true" ;; -r|--reboot) - reboot="true"G + reboot="true" ;; esac done @@ -27,12 +27,11 @@ done printf ""$font_colored_bold">> system update started..."$font_default"\n" printf ""$font_colored"> updating packages..."$font_default"\n" -[[ "$noconfirm" ]] && apk update --progress || apk update --progress --interactive -[[ "$noconfirm" ]] && apk upgrade --progress || apk update --progress --interactive +[[ "$noconfirm" ]] && apk --update-cache upgrade --progress || apk --update-cache upgrade --progress --interactive -printf ""$font_colored"> cleaning cache..."$font_default"\n" -apk cache clean &> /dev/null -rm -rf "/var/cache/apk/*" +#printf ""$font_colored"> cleaning cache..."$font_default"\n" +#apk cache clean &> /dev/null +#rm -rf "/var/cache/apk/*" orphans="$(apk list --orphaned | awk '{print $1}' 2> /dev/null)" if [[ "$orphans" ]]; then From 32f8ce1c5566f99f25804207d7eed97cc15795b3 Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 5 Nov 2024 16:27:47 +0100 Subject: [PATCH 5/5] fix alpine update script --- scripts/update/alpine.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/update/alpine.sh b/scripts/update/alpine.sh index 02ff4a4..56dfb0d 100755 --- a/scripts/update/alpine.sh +++ b/scripts/update/alpine.sh @@ -29,10 +29,6 @@ printf ""$font_colored_bold">> system update started..."$font_default"\n" printf ""$font_colored"> updating packages..."$font_default"\n" [[ "$noconfirm" ]] && apk --update-cache upgrade --progress || apk --update-cache upgrade --progress --interactive -#printf ""$font_colored"> cleaning cache..."$font_default"\n" -#apk cache clean &> /dev/null -#rm -rf "/var/cache/apk/*" - orphans="$(apk list --orphaned | awk '{print $1}' 2> /dev/null)" if [[ "$orphans" ]]; then orphans="$(printf "$orphans" | tr '\n' ' ')" @@ -45,6 +41,10 @@ fi script="$(dirname $(realpath $0))/conf.d/$(hostname).sh" [[ -x "$script" ]] && printf ""$font_colored"> executing script "$script"..."$font_default"\n" && (. "$script") +printf ""$font_colored"> cleaning cache..."$font_default"\n" +apk cache clean &> /dev/null +rm -rf "/var/cache/apk/*" + printf ""$font_colored_bold">> system updated finished!"$font_default"\n" [[ ! "$reboot" ]] && exit 0