Fixed nbd-disconnect-root for sysv systems
This commit is contained in:
parent
aba3da2a7f
commit
3bba9e87a1
|
@ -4,7 +4,7 @@
|
||||||
# errors occur, and if it isn't, then # the nbd-server process on the server
|
# errors occur, and if it isn't, then # the nbd-server process on the server
|
||||||
# doesn't terminate.
|
# doesn't terminate.
|
||||||
# Called by init scripts on reboot or shutdown.
|
# Called by init scripts on reboot or shutdown.
|
||||||
|
|
||||||
case "$RUNLEVEL" in
|
case "$RUNLEVEL" in
|
||||||
0)
|
0)
|
||||||
key="o"
|
key="o"
|
||||||
|
@ -12,29 +12,29 @@ case "$RUNLEVEL" in
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
key="b"
|
key="b"
|
||||||
command="reboot"
|
command="reboot -d -f -i"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "nbd-disconnect should only be called by initscripts on reboot/shutdown." >&2
|
echo "nbd-disconnect should only be called by initscripts on reboot/shutdown." >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
# Stop trapping
|
# Stop trapping
|
||||||
trap - 0 HUP INT QUIT KILL SEGV PIPE TERM
|
trap - 0 HUP INT QUIT KILL SEGV PIPE TERM
|
||||||
|
|
||||||
# ltsp-client-core.upstart needs "console output" to show stderr
|
# ltsp-client-core.upstart needs "console output" to show stderr
|
||||||
echo "nbd-disconnect executing: " >&2
|
echo "nbd-disconnect executing: " >&2
|
||||||
# Cache the command in order to use it after nbd-client disconnects
|
# Cache the command in order to use it after nbd-client disconnects
|
||||||
$command --version >/dev/null 2>&1
|
$command --version >/dev/null 2>&1
|
||||||
nbd-client -d "$root"
|
nbd-client -d "$root"
|
||||||
$command
|
$command
|
||||||
|
|
||||||
# Hopefully this should never be reached
|
# Hopefully this should never be reached
|
||||||
echo "$key" > /proc/sysrq-trigger
|
echo "$key" > /proc/sysrq-trigger
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disconnect swap nbd devices first
|
# Disconnect swap nbd devices first
|
||||||
while read device etc; do
|
while read device etc; do
|
||||||
case "$device" in
|
case "$device" in
|
||||||
|
@ -54,7 +54,7 @@ while read device etc; do
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < /proc/swaps
|
done < /proc/swaps
|
||||||
|
|
||||||
# If we're not using an nbd root, exit
|
# If we're not using an nbd root, exit
|
||||||
unset root
|
unset root
|
||||||
for param in $(cat /proc/cmdline); do
|
for param in $(cat /proc/cmdline); do
|
||||||
|
@ -65,7 +65,7 @@ for param in $(cat /proc/cmdline); do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
test -n "$root" || exit 0
|
test -n "$root" || exit 0
|
||||||
|
|
||||||
trap "disconnect" 0 HUP INT QUIT KILL SEGV PIPE TERM
|
trap "disconnect" 0 HUP INT QUIT KILL SEGV PIPE TERM
|
||||||
sync
|
sync
|
||||||
# Give up to 5 seconds for other services to be called.
|
# Give up to 5 seconds for other services to be called.
|
||||||
|
|
Loading…
Reference in New Issue