view core/rc/rc.shutdown @ 889:df3b53914b27

emulation/libretro-vbam: initial import, closes #2188
author David Demelier <markand@malikania.fr>
date Sun, 25 Aug 2019 17:53:45 +0200
parents 58211c615a8c
children
line wrap: on
line source

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

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

echo "Terminating all processes."
killall5 -15

# Stop networking.
if [ -x /etc/rc.networking ]; then
	/etc/rc.networking stop
fi

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 /

if [ "$1" = "0" ]; then
	poweroff -d -f
else
	reboot -d -f
fi