diff vinit.shutdown @ 4:3db6ca1fe07d

misc: merge scripts from vinit-script While here, make /etc tunable.
author David Demelier <markand@malikania.fr>
date Wed, 10 Nov 2021 16:34:41 +0100
parents
children 7d40d4ae7377
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vinit.shutdown	Wed Nov 10 16:34:41 2021 +0100
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# @SYSCONFDIR@/rc.shutdown -- reboot and halt script
+#
+# Copyright (c) 2019-2021 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+trap "" INT TERM
+
+if [ -f @SYSCONFDIR@/vinit.conf ]; then
+	. @SYSCONFDIR@/vinit.conf
+fi
+
+# Stop networking.
+if [ -x @SYSCONFDIR@/vinit.net ]; then
+	@SYSCONFDIR@/vinit.net stop
+fi
+
+echo "Terminating all processes."
+killall5 -15
+
+echo "Unmounting all filesystems."
+halt -w
+swapoff -a
+
+echo "Remounting / read-only"
+umount -a -d -r -t nosysfs,noproc,nodevtmpfs
+umount -a -r
+mount -o remount,ro /
+
+case "$1" in
+"halt")
+	halt -f ;;
+"poweroff")
+	poweroff -f ;;
+"reboot")
+	reboot -f ;;
+esac