ambevar-dotfiles/.bin/creboot

39 lines
516 B
Plaintext
Raw Normal View History

2014-03-04 11:05:50 +01:00
#!/bin/sh
rawname=${0##*/}
rawname=${rawname#c}
usage () {
cat <<EOF>&2
Usage: ${0##*/}
2014-03-04 11:05:50 +01:00
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
usage
exit
2014-03-04 11:05:50 +01:00
fi
## Check values.
case $rawname in
poweroff) ;;
reboot) ;;
halt) ;;
*)
usage
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
$rawname
2016-06-23 23:18:36 +02:00
else
## 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