25 lines
571 B
Bash
25 lines
571 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
# 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
|
||
|
[[ ! -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 "
|
||
|
args="$args$arg"
|
||
|
done
|
||
|
|
||
|
# execute update script
|
||
|
if [[ "$EUID" == "0" ]]; then
|
||
|
"$script" $args
|
||
|
else
|
||
|
sudo "$script" $args
|
||
|
fi
|