summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-05-16 09:35:42 +0200
committerErich Eckner <git@eckner.net>2019-05-16 09:35:42 +0200
commit7ee74cc1d31c4d3e7bc8d8d65222fca96cc3a7ab (patch)
tree4eb6bdd3b56b723948a4a433a40608632e454562
parentba6cb3fa1e6f22f6ecd76399af6fe34d00116f98 (diff)
downloadcheck-kernel-7ee74cc1d31c4d3e7bc8d8d65222fca96cc3a7ab.tar.xz
check-kernel.conf and reboot_check_hook() newv0.5.1
-rw-r--r--.gitignore1
-rw-r--r--Makefile3
-rw-r--r--check-kernel.conf.in8
-rw-r--r--check-kernel.in12
4 files changed, 23 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 31f83a4..769d934 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
check-kernel
+check-kernel.conf
man.commons
*.common
*.1
diff --git a/Makefile b/Makefile
index 151cf87..5fb707e 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ MANDIR = /usr/share/man
VERSION = 0.5
-all: man.commons check-kernel check-kernel.1
+all: man.commons check-kernel check-kernel.conf check-kernel.1
%: %.in
sed " \
@@ -47,6 +47,7 @@ all: man.commons check-kernel check-kernel.1
install: all
install -D -m0755 check-kernel $(DESTDIR)$(BINDIR)/check-kernel
+ install -D -m0644 check-kernel.conf $(DESTDIR)$(ETCDIR)/check-kernel.conf
install -D -m0644 check-kernel.1 $(DESTDIR)$(MANDIR)/man1/check-kernel.1
clean:
diff --git a/check-kernel.conf.in b/check-kernel.conf.in
new file mode 100644
index 0000000..dc40a52
--- /dev/null
+++ b/check-kernel.conf.in
@@ -0,0 +1,8 @@
+# Configuration for check-kernel
+# Should be located at #ETCDIR#/check-kernel.conf
+
+# a hook which should check if a reboot is safe and wait or return
+# non-zero if it is not
+reboot_check_hook() {
+ true
+}
diff --git a/check-kernel.in b/check-kernel.in
index c138152..d9c3717 100644
--- a/check-kernel.in
+++ b/check-kernel.in
@@ -46,6 +46,13 @@ while true; do
shift
done
+if [ -f '#ETCDIR#/check-kernel.conf' ]; then
+ if ! . '#ETCDIR#/check-kernel.conf'; then
+ >&2 printf 'Sourcing "#ETCDIR#/check-kernel.conf" failed.\n'
+ exit 1
+ fi
+fi
+
unset installed
if which pacman >/dev/null 2>&1; then
# arch linux
@@ -133,6 +140,11 @@ else
"${installed}" \
"${running}"
if ${reboot}; then
+ if declare -F reboot_check_hook >/dev/null \
+ && ! reboot_check_hook; then
+ >&2 printf 'reboot_check_hook() failed.\n'
+ exit 1
+ fi
>&2 printf 'Press enter to reboot ...'
read s
if [ -z "${s}" ]; then