.dots/scripts/update/update.sh

19 lines
507 B
Bash
Raw Normal View History

2024-12-10 09:16:00 +01:00
#!/usr/bin/env zsh
2024-09-26 11:05:50 +02:00
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
# get distro and update script path
distro="$(grep "^ID" /etc/*release | cut -d "=" -f2)"
script="$(dirname $(realpath $0))/$distro.sh"
# check if update script exists
2024-12-10 09:16:00 +01:00
[[ ! -x "$script" ]] && printf "error: update script '"$script"' does not exist or is not executable!\n" >&2 && exit 1
2024-09-26 11:05:50 +02:00
# execute update script
2024-12-10 09:16:00 +01:00
if [[ "$(id -u)" -eq 0 ]] || [[ "$distro" == "arch" ]]; then
"$script" $@
2024-09-26 11:05:50 +02:00
else
sudo "$script" $@
2024-09-26 11:05:50 +02:00
fi