2014-03-04 11:05:50 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
rawname=${0##*/}
|
|
|
|
rawname=${rawname#c}
|
|
|
|
|
2014-11-12 16:15:39 +01:00
|
|
|
usage () {
|
|
|
|
cat <<EOF
|
2014-03-04 11:05:50 +01:00
|
|
|
Usage: ${1##*/}
|
|
|
|
|
2016-06-23 23:18:36 +02:00
|
|
|
Run 'sessionclean' if available and $rawname the system.
|
2014-03-04 11:05:50 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "-h" ]; then
|
2014-11-12 16:15:39 +01:00
|
|
|
usage "$0"
|
|
|
|
exit
|
2014-03-04 11:05:50 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
## Check values.
|
|
|
|
case $rawname in
|
2014-11-12 16:15:39 +01:00
|
|
|
poweroff) ;;
|
|
|
|
reboot) ;;
|
|
|
|
halt) ;;
|
|
|
|
*)
|
|
|
|
usage "$0"
|
|
|
|
exit ;;
|
2014-03-04 11:05:50 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
command -v sessionclean >/dev/null 2>&1 && sessionclean
|
|
|
|
|
|
|
|
if command -v systemctl >/dev/null 2>&1; then
|
2014-11-12 16:15:39 +01:00
|
|
|
$rawname
|
2016-06-23 23:18:36 +02:00
|
|
|
else
|
2014-11-12 16:15:39 +01:00
|
|
|
## If you do not want to get prompted for your password, configure sudo
|
|
|
|
## properly.
|
2016-06-23 23:18:36 +02:00
|
|
|
sudo "$rawname"
|
2014-03-04 11:05:50 +01:00
|
|
|
fi
|