view vinit.shutdown @ 7:7d40d4ae7377 default tip @

misc: update copyright years
author David Demelier <markand@malikania.fr>
date Sun, 02 Jan 2022 10:26:58 +0100
parents 3db6ca1fe07d
children
line wrap: on
line source

#!/bin/sh
#
# @SYSCONFDIR@/rc.shutdown -- reboot and halt script
#
# Copyright (c) 2019-2022 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