From 681594c11c197cbffdbac57e6d3ad7490a662ff9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 8 Oct 2021 19:31:08 +0200 Subject: Adding shutdown handling in bfh-container. Signed-off-by: Daniel Baumann --- debian/bfh-container.postrm | 30 ++++++++++++++++++++++++++++++ debian/bfh-container.preinst | 32 ++++++++++++++++++++++++++++++++ debian/local/shutdown | 13 +++++++++++++ debian/local/shutdown.txt | 6 ++++++ debian/rules | 16 ++++++++++++++++ 5 files changed, 97 insertions(+) create mode 100755 debian/bfh-container.postrm create mode 100755 debian/bfh-container.preinst create mode 100755 debian/local/shutdown create mode 100644 debian/local/shutdown.txt 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 -- cgit v1.2.3