2012-02-03 15:13:37 +01:00
|
|
|
#!/bin/ash
|
2011-10-24 02:24:18 +02:00
|
|
|
|
|
|
|
# /oldroot depends on things inside /oldroot/run/archiso...
|
|
|
|
mkdir /oldrun
|
2012-03-16 03:43:58 +01:00
|
|
|
mount -n --move /oldroot/run /oldrun
|
2011-10-24 02:24:18 +02:00
|
|
|
|
|
|
|
# Unmount all mounts now.
|
|
|
|
umount $(mount | awk '$3 ~/^\/oldroot/ {print $3}' | sort -r)
|
|
|
|
|
|
|
|
# Remove all dm-snapshot devices.
|
|
|
|
dmsetup remove_all
|
|
|
|
|
2012-02-23 03:52:06 +01:00
|
|
|
# Remove all loopback devices.
|
|
|
|
for _lup in $(grep ^/dev/loop /oldrun/archiso/used_block_devices | tac); do
|
2011-10-24 02:24:18 +02:00
|
|
|
if ! losetup -d ${_lup} 2> /dev/null; then
|
|
|
|
umount -d ${_lup}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Unmount the space used to store *.cow.
|
|
|
|
umount /oldrun/archiso/cowspace
|
|
|
|
|
|
|
|
# Unmount boot device if needed (no copytoram=y used)
|
|
|
|
if [[ ! -d /oldrun/archiso/copytoram ]]; then
|
2012-02-23 03:52:06 +01:00
|
|
|
if [[ -d /oldrun/archiso/img_dev ]]; then
|
2011-10-24 02:24:18 +02:00
|
|
|
umount /oldrun/archiso/img_dev
|
2012-02-23 03:52:06 +01:00
|
|
|
else
|
|
|
|
umount /oldrun/archiso/bootmnt
|
2011-10-24 02:24:18 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# reboot / poweroff / halt, depending on the argument passed by init
|
|
|
|
# if something invalid is passed, we halt
|
|
|
|
case "$1" in
|
|
|
|
reboot|poweroff|halt) "$1" -f ;;
|
|
|
|
*) halt -f;;
|
|
|
|
esac
|