I've been using this script for quite some time and it works very well and is nice and simple to use. But, it didn't log what I did and when, until now! :)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
set -x
#: Title            : lrs
#: Date             : February 2014
#: Author           : Sharon Kimble
#: Version          : 1.0
#: Description      : to help you to decide whether to reboot or shutdown
#: Options          : 2, both listed in variables
#: License          : GNU GPL 3.0 or later
####################################################
# Variables
log="/home/$USER/logs/reboot.txt"
killbrowser="/usr/bin/killall chrome; /usr/bin/killall chromium"
####################################################
exec > >(tee -a $log) 2>&1
echo
{
    read -n1 -p "$(tput setaf 1)  Do you want to logoff, reboot, shutdown or just quit? [l/r/s/q] " lrsq
    echo; echo "$(date +%Y-%m-%d\ %H:%M:%S) Answer: $lrsq" >> $log
   case "$lrsq" in
        [Ll]* ) $killbrowser; exit && exit;;
        [Rr]* ) $killbrowser; sudo /sbin/reboot $*; echo; exit;;
        [Ss]* ) $killbrowser; sudo /sbin/shutdown $*; echo; exit;;
        [Qq]* ) echo; exit;;
        * )
    esac
}


Comments

comments powered by Disqus