.dots/scripts/update/update.sh

28 lines
676 B
Bash
Raw Normal View History

2024-10-28 13:26:03 +01:00
#!/usr/bin/env sh
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-10-28 13:57:14 +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
args=""
for arg in "$@"; do
2024-10-28 13:57:14 +01:00
[ -n "$args" ] && args="$args "
2024-09-26 11:05:50 +02:00
args="$args$arg"
done
# execute update script
2024-11-05 15:43:50 +01:00
#if [ "$distro" == "arch" ]; then
# "$script" $args
if [ "$(id -u)" -eq 0 ] || [ "$distro" == "arch" ]; then
#elif [ "$(id -u)" -eq 0 ]; then
"$script" $args
2024-09-26 11:05:50 +02:00
else
sudo "$script" $args
fi