use halt if available
This commit is contained in:
parent
0afbcc55f2
commit
ff28e04a20
|
@ -1,4 +1,7 @@
|
||||||
spark-rc
|
# spark-rc
|
||||||
========
|
|
||||||
|
|
||||||
A simple rc script to kickstart your system.
|
A simple rc script to kickstart your system.
|
||||||
|
|
||||||
|
## depends
|
||||||
|
|
||||||
|
* Enabled sysrq or halt from suckless.org's ubase.
|
||||||
|
|
15
rc.in
15
rc.in
|
@ -128,10 +128,21 @@ rc.boot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.halt() {
|
rc.halt() {
|
||||||
|
if type -P halt; then
|
||||||
|
function rc.halt_poweroff { halt -p; }
|
||||||
|
function rc.halt_reboot { halt -r; }
|
||||||
|
elif [[ -f /proc/sysrq-trigger ]]; then
|
||||||
|
function rc.halt_poweroff { echo 'o' > /proc/sysrq-trigger; }
|
||||||
|
function rc.halt_reboot { echo 'b' > /proc/sysrq-trigger; }
|
||||||
|
else
|
||||||
|
printf 'Cannot halt, please install halt from suckless.org ubase or enable sysrq.\n'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
poweroff|shutdown) echo 'o' > /proc/sysrq-trigger;;
|
|
||||||
halt) :;;
|
halt) :;;
|
||||||
reboot|*) echo 'b' > /proc/sysrq-trigger;;
|
poweroff|shutdown) rc.halt_poweroff;;
|
||||||
|
reboot|*) rc.halt_reboot;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user