31 lines
562 B
Bash
31 lines
562 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
SCRIPTNAME="$( basename -- "$0" )"
|
||
|
|
||
|
ensure_root () {
|
||
|
if [[ $EUID -ne 0 ]]; then
|
||
|
echo "This script must be run as root"
|
||
|
exit 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
ensure_not_root () {
|
||
|
if [[ $EUID -eq 0 ]]; then
|
||
|
echo "This script must not be run as root"
|
||
|
exit 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
ensure_pwd_is_scriptdir () {
|
||
|
if [[ $PWD != $ABSDIR ]]; then
|
||
|
echo "Please cd in the script directory before running it :"
|
||
|
echo "cd ${ABSDIR}"
|
||
|
echo "./${SCRIPTNAME}"
|
||
|
exit 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
ensure_systemd_as_user_dir_exists () {
|
||
|
mkdir -p ${HOME}/.config/systemd/user/
|
||
|
}
|