summaryrefslogtreecommitdiff
path: root/upstart/cloud-log-shutdown.conf
blob: 278b9c060a55321ba07a541b439eba61e29f657e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# log shutdowns and reboots to the console (/dev/console)
# this is useful for correlating logs
start on runlevel PREVLEVEL=2

task
console output

script
  # runlevel(7) says INIT_HALT will be set to HALT or POWEROFF
  date=$(date --utc)
  case "$RUNLEVEL:$INIT_HALT" in
     6:*)        mode="reboot";;
     0:HALT)     mode="halt";;
     0:POWEROFF) mode="poweroff";;
     0:*)        mode="shutdown-unknown";;
  esac
  { read seconds idle < /proc/uptime; } 2>/dev/null || :
  echo "$date: shutting down for $mode${seconds:+ [up ${seconds%.*}s]}."
end script