fix minor issues

This commit is contained in:
Daniel Sommer 2024-09-26 13:45:53 +02:00
parent 26c70398ef
commit e9740ecf56
3 changed files with 50 additions and 9 deletions

View file

@ -4,7 +4,7 @@
# license: MIT # license: MIT
# exit on ctrl-c # exit on ctrl-c
trap 'printf ""$font_colored_bold"\n>> stopping system update after "$SECONDS" seconds..."$font_default"\n" && exit 1' SIGINT trap 'printf ""$font_colored_bold"\n>> system update aborted!"$font_default"\n" && exit 1' SIGINT
# font styles & colors # font styles & colors
font_default="\e[0m" font_default="\e[0m"
@ -27,23 +27,23 @@ done
printf ""$font_colored_bold">> system update started..."$font_default"\n" printf ""$font_colored_bold">> system update started..."$font_default"\n"
printf ""$font_colored"> updating packages..."$font_default"\n" printf ""$font_colored"> updating packages..."$font_default"\n"
[[ "$noconfirm" ]] && /sbin/apk update --progress || /sbin/apk update --progress --interactive [[ "$noconfirm" ]] && apk update --progress || apk update --progress --interactive
[[ "$noconfirm" ]] && /sbin/apk upgrade --progress || /sbin/apk update --progress --interactive [[ "$noconfirm" ]] && apk upgrade --progress || apk update --progress --interactive
printf ""$font_colored"> cleaning cache..."$font_default"\n" printf ""$font_colored"> cleaning cache..."$font_default"\n"
/sbin/apk cache clean &> /dev/null apk cache clean &> /dev/null
rm -rf "/var/cache//sbin/apk/*" rm -rf "/var/cache/apk/*"
orphans="$(/sbin/apk list --orphaned | awk '{print $1}' 2> /dev/null)" orphans="$(apk list --orphaned | awk '{print $1}' 2> /dev/null)"
if [[ "$orphans" ]]; then if [[ "$orphans" ]]; then
orphans="$(printf "$orphans" | tr '\n' ' ')" orphans="$(printf "$orphans" | tr '\n' ' ')"
printf ""$font_colored"> removing orphaned packages..."$font_default"\n" printf ""$font_colored"> removing orphaned packages..."$font_default"\n"
[[ "$noconfirm" ]] && /sbin/apk del --purge --progress $orphans || /sbin/apk del --purge --progress --interactive $orphans [[ "$noconfirm" ]] && apk del --purge --progress $orphans || apk del --purge --progress --interactive $orphans
fi fi
[[ -f "/etc/motd" ]] && printf ""$font_colored"> removing '/etc/motd'..."$font_default"\n" && rm -f "/etc/motd" [[ -f "/etc/motd" ]] && printf ""$font_colored"> removing '/etc/motd'..."$font_default"\n" && rm -f "/etc/motd"
script="$(realpath $(dirname $0))/update-$(cat /etc/hostname).sh" script="$(dirname $(realpath $0))/conf.d/$(hostname).sh"
[[ -x "$script" ]] && printf ""$font_colored"> executing script "$script"..."$font_default"\n" && (. "$script") [[ -x "$script" ]] && printf ""$font_colored"> executing script "$script"..."$font_default"\n" && (. "$script")
printf ""$font_colored_bold">> system updated finished!"$font_default"\n" printf ""$font_colored_bold">> system updated finished!"$font_default"\n"

41
scripts/update/conf.d/aria.sh Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
ariang="/srv/ariang"
user="nginx"
[[ ! -e "$ariang" ]] && printf "> error: directory '"$ariang"' does not exist\n" 1>&2 && exit 1
file="$(find $ariang -type f -iname 'aria-ng*.min.js' -exec realpath {} \;)"
[[ -z "$file" ]] && printf "> error: could not determine file to extract the current version from\n" 1>&2 && exit 1
current_version="$(awk -F'buildVersion:"|\",buildCommit' '{print $2}' "$file" | xargs | cut -d "v" -f2)"
[[ -z "$current_version" ]] && printf "> error: could not determine current version\n" 1>&2 && exit 1
latest_release="$(curl -s -L https://api.github.com/repos/mayswind/AriaNg/releases/latest | grep tag_name | cut -d "\"" -f4 | cut -d "v" -f2)"
[[ -z "$latest_release" ]] && printf "> error: could not determine latest release\n" 1>&2 && exit 1
[[ "$current_version" == "$latest_release" ]] && printf "> current version '"$current_version"' is already up to date\n" && exit 0
tmp="$(mktemp -d)"
printf "> downloading latest release '"$latest_release"' to temporary directory '"$tmp"'..."
curl -s -L -o "$tmp/ariang-$latest_release.zip" "https://github.com/mayswind/AriaNg/releases/download/$latest_release/AriaNg-$latest_release.zip" &> /dev/null
[[ "$?" != "0" ]] && printf " error!\n" 1>&2 && exit 1
printf " done!\n"
printf "> extracting downloaded archive..."
cd "$tmp"
unzip "ariang-$latest_release.zip" &> /dev/null
[[ "$?" != "0" ]] && printf " error!\n" 1>&2 && exit 1
rm -rf "ariang-$latest_release.zip" &> /dev/null
printf " done!\n"
printf "> moving extracted files..."
rm -rf "$ariang" &> /dev/null
mv "$tmp" "$ariang" &> /dev/null
printf " done!\n"
printf "> setting correct permissions..."
chown -R "$user":"$user" "$ariang"
printf " done!\n"

View file

@ -4,7 +4,7 @@
# license: MIT # license: MIT
# exit on ctrl-c # exit on ctrl-c
trap 'printf ""$font_colored_bold"\n>> stopping system update after "$SECONDS" seconds..."$font_default"\n" && exit 1' SIGINT trap 'printf ""$font_colored_bold"\n>> system update aborted after "$SECONDS" seconds!"$font_default"\n" && exit 1' SIGINT
# font styles & colors # font styles & colors
font_default="\e[0m" font_default="\e[0m"