summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2021-10-08 17:31:08 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2021-10-08 18:06:39 +0000
commit681594c11c197cbffdbac57e6d3ad7490a662ff9 (patch)
treeed4944ee1ba8adba9c75d315e4d600b6d5fc46f9
parentAdding jq to bfh-base-system depends. (diff)
downloadbfh-metapackages-681594c11c197cbffdbac57e6d3ad7490a662ff9.tar.xz
bfh-metapackages-681594c11c197cbffdbac57e6d3ad7490a662ff9.zip
Adding shutdown handling in bfh-container.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
-rwxr-xr-xdebian/bfh-container.postrm30
-rwxr-xr-xdebian/bfh-container.preinst32
-rwxr-xr-xdebian/local/shutdown13
-rw-r--r--debian/local/shutdown.txt6
-rwxr-xr-xdebian/rules16
5 files changed, 97 insertions, 0 deletions
diff --git a/debian/bfh-container.postrm b/debian/bfh-container.postrm
new file mode 100755
index 0000000..ec69346
--- /dev/null
+++ b/debian/bfh-container.postrm
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+case "${1}" in
+ remove)
+ for FILE in halt poweroff reboot shutdown coldreboot
+ do
+ dpkg-divert --package bfh-container --quiet --remove --rename --divert /lib/container/divert/${FILE}.orig /sbin/${FILE}
+ done
+
+ for FILE in pm-hibernate pm-suspend pm-suspend-hybrid
+ do
+ dpkg-divert --package bfh-container --quiet --remove --rename --divert /lib/container/divert/${FILE}.orig /usr/sbin/${FILE}
+ done
+ ;;
+
+ purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`${1}'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/bfh-container.preinst b/debian/bfh-container.preinst
new file mode 100755
index 0000000..335d160
--- /dev/null
+++ b/debian/bfh-container.preinst
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -e
+
+case "${1}" in
+ install|upgrade)
+ mkdir -p /lib/container/divert
+
+ for FILE in halt poweroff reboot shutdown coldreboot
+ do
+ dpkg-divert --package bfh-container --quiet --add --rename --divert /lib/container/divert/${FILE}.orig /sbin/${FILE}
+ done
+
+ for FILE in pm-hibernate pm-suspend pm-suspend-hybrid
+ do
+ dpkg-divert --package bfh-container --quiet --add --rename --divert /lib/container/divert/${FILE}.orig /usr/sbin/${FILE}
+ done
+ ;;
+
+ abort-upgrade)
+
+ ;;
+
+ *)
+ echo "preinst called with unknown argument \`${1}'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/local/shutdown b/debian/local/shutdown
new file mode 100755
index 0000000..30e959d
--- /dev/null
+++ b/debian/local/shutdown
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+echo "${0}: disabled in systemd-nspawn container"
+
+if [ -e /etc/compute-tools/shutdown.txt ]
+then
+ cat /etc/compute-tools/shutdown.txt
+elif [ -e /usr/share/container/shutdown.txt ]
+then
+ cat /usr/share/container/shutdown.txt
+fi
+
+exit 1
diff --git a/debian/local/shutdown.txt b/debian/local/shutdown.txt
new file mode 100644
index 0000000..b082bf0
--- /dev/null
+++ b/debian/local/shutdown.txt
@@ -0,0 +1,6 @@
+
+Linux container share the kernel of the host system they are running on,
+there is no need to reboot just the container.
+
+However, please contact your system administrator to reboot this
+container from the host system.
diff --git a/debian/rules b/debian/rules
index b9a70ab..7bb7904 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,22 @@ override_dh_auto_install:
dh_auto_install -- DESTDIR=$(CURDIR)/debian/bfh-base-system
execute_after_dh_auto_install:
+ # shutdown
+ mkdir -p debian/bfh-container/sbin
+ for FILE in halt poweroff reboot shutdown coldreboot; \
+ do \
+ cp debian/local/shutdown debian/bfh-container/sbin/$${FILE}; \
+ done
+
+ mkdir -p debian/bfh-container/usr/sbin
+ for FILE in pm-hibernate pm-suspend pm-suspend-hybrid; \
+ do \
+ cp debian/local/shutdown debian/bfh-container/usr/sbin/$${FILE}; \
+ done
+
+ mkdir -p debian/bfh-container/usr/share/container
+ cp debian/local/shutdown.txt debian/bfh-container/usr/share/container
+
# removing useless files
rm -f debian/tmp/usr/share/doc/*/CHANGELOG.txt
rm -f debian/tmp/usr/share/doc/*/LICENSE.txt