39 lines
516 B
Plaintext
39 lines
516 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
rawname=${0##*/}
|
||
|
rawname=${rawname#c}
|
||
|
|
||
|
usage () {
|
||
|
cat <<EOF>&2
|
||
|
Usage: ${0##*/}
|
||
|
|
||
|
Run 'sessionclean' if available and $rawname the system.
|
||
|
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
if [ "$1" = "-h" ]; then
|
||
|
usage
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
## Check values.
|
||
|
case $rawname in
|
||
|
poweroff) ;;
|
||
|
reboot) ;;
|
||
|
halt) ;;
|
||
|
*)
|
||
|
usage
|
||
|
exit ;;
|
||
|
esac
|
||
|
|
||
|
command -v sessionclean >/dev/null 2>&1 && sessionclean
|
||
|
|
||
|
if command -v systemctl >/dev/null 2>&1; then
|
||
|
$rawname
|
||
|
else
|
||
|
## If you do not want to get prompted for your password, configure sudo
|
||
|
## properly.
|
||
|
sudo "$rawname"
|
||
|
fi
|