Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
oreinert committed Mar 27, 2018
1 parent 95b9c2c commit 5e7be4f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dirtyboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /bin/bash

DIRTYBOOT_MARK=${DIRTYBOOT_DIR:=/var/lib}/dirtyboot

function onBoot {
if [ -f "$DIRTYBOOT_MARK" ]; then
logger -t dirtyboot -p notice "Dirty reboot detected"
fi
if ! echo "Records last boot time" > "$DIRTYBOOT_MARK"; then
logger -t dirtyboot -p error "Unable to create boot mark"
fi
}

function onShutdown {
if [ -e "$DIRTYBOOT_MARK" ]; then
rm "$DIRTYBOOT_MARK"
fi
}

case $1 in
start)
onBoot
;;
stop)
onShutdown
;;
*)
echo "Usage: $0 start | stop"
exit 1
;;
esac

11 changes: 11 additions & 0 deletions dirtyboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Dirty boot detector

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/dirtyboot start
ExecStop=/usr/sbin/dirtyboot stop

[Install]
WantedBy=basic.target

0 comments on commit 5e7be4f

Please sign in to comment.