#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Licensed under the GPLv2 # # Copyright 2011, Red Hat, Inc. # Harald Hoyer ACTION="$1" export TERM=linux export PATH=/usr/sbin:/usr/bin:/sbin:/bin . /lib/dracut-lib.sh trap "emergency_shell --shutdown shutdown Signal caught!" 0 getarg 'rd.break=pre-shutdown' && emergency_shell --shutdown pre-shutdown "Break before pre-shutdown" umount_a() { local _did_umount="n" while read a mp a; do if strstr "$mp" oldroot; then if umount "$mp"; then _did_umount="y" echo "Unmounted $mp." fi fi done /dev/null || break _cnt=$(($_cnt+1)) done [ $_cnt -ge 40 ] && umount_a _check_shutdown() { local __f local __s=1 for __f in $hookdir/shutdown/*.sh; do [ -e "$__f" ] || continue ( . "$__f" $1 ) if [ $? -eq 0 ]; then rm -f $__f __s=0 fi done return $__s } while _check_shutdown; do : done _check_shutdown final getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown" [ "$ACTION" = "reboot" ] && reboot -f -d -n [ "$ACTION" = "poweroff" ] && poweroff -f -d -n [ "$ACTION" = "halt" ] && halt -f -d -n [ "$ACTION" = "kexec" ] && kexec -e warn "Shutdown called without an argument. Rebooting!" reboot -f -d -n