diff options
author | Michael Janczyk | 2012-12-11 17:20:53 +0100 |
---|---|---|
committer | Michael Janczyk | 2012-12-11 17:20:53 +0100 |
commit | e66413628d95f8c9d91a2080768501946c0d5514 (patch) | |
tree | 01f729a3327b5a21f2a123f3b783faadd91e86dc /src/os-plugins | |
parent | Added missing plugin files for RHEL, Scientific Linux and CentOS Linux. (diff) | |
download | core-e66413628d95f8c9d91a2080768501946c0d5514.tar.gz core-e66413628d95f8c9d91a2080768501946c0d5514.tar.xz core-e66413628d95f8c9d91a2080768501946c0d5514.zip |
sysrqshutdown plugin changed.
now there is a second script which does the sysrq requests which is started with nohup, so that one can logout from ssh first
Diffstat (limited to 'src/os-plugins')
3 files changed, 50 insertions, 21 deletions
diff --git a/src/os-plugins/plugins/sysrqshutdown/OpenSLX/OSPlugin/sysrqshutdown.pm b/src/os-plugins/plugins/sysrqshutdown/OpenSLX/OSPlugin/sysrqshutdown.pm index bfc274d4..c30ec5dc 100644 --- a/src/os-plugins/plugins/sysrqshutdown/OpenSLX/OSPlugin/sysrqshutdown.pm +++ b/src/os-plugins/plugins/sysrqshutdown/OpenSLX/OSPlugin/sysrqshutdown.pm @@ -78,7 +78,8 @@ sub installationPhase if (! -e "/sbin/shutdown.slxorig") { system("mv /sbin/shutdown /sbin/shutdown.slxorig"); system("cp -p $pluginBasePath/shutdown /sbin/; - cp -p $pluginBasePath/shutdown /opt/openslx/plugin-repo/$pluginName"); + cp -p $pluginBasePath/shutdown $pluginBasePath/sysrqshutdown.sh \ + /opt/openslx/plugin-repo/$pluginName"); chmod 0755, "/sbin/shutdown"; } # else assume reinstall diff --git a/src/os-plugins/plugins/sysrqshutdown/files/shutdown b/src/os-plugins/plugins/sysrqshutdown/files/shutdown index a27481d7..1866d516 100644 --- a/src/os-plugins/plugins/sysrqshutdown/files/shutdown +++ b/src/os-plugins/plugins/sysrqshutdown/files/shutdown @@ -1,7 +1,7 @@ #!/bin/bash # ----------------------------------------------------------------------------- # Copyright (c) 2010 - RZ Uni FR -# Copyright (c) 2010 - OpenSLX GmbH +# Copyright (c) 2010 - 2012 OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -12,7 +12,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # shutdown -# - Script for SYSRQ shutdown +# - Script which prepares for SYSRQ shutdown ################################################################################ . /etc/opt/openslx/openslx.conf @@ -22,30 +22,19 @@ ################################################################################ PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins -PLUGINCONFVMGRID=${PLUGINCONFROOT}/sysrqshutdown -# include general configuration from vmgrid -if [ -f ${PLUGINCONFVMGRID}/sysrqshutdown.conf ]; then - . ${PLUGINCONFVMGRID}/sysrqshutdown.conf +PLUGINCONFSYSRQ=${PLUGINCONFROOT}/sysrqshutdown +PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/sysrqshutdown + +# include general configuration from sysrqshutdown +if [ -f ${PLUGINCONFSYSRQ}/sysrqshutdown.conf ]; then + . ${PLUGINCONFSYSRQ}/sysrqshutdown.conf else sysrqshutdown_active=0 fi if [ ${sysrqshutdown_active} -eq 1 ]; then - # check if reboot or halt - if echo "$@" | grep -qe '-r now'; then - for i in $(echo s u b); do - echo $i > /proc/sysrq-trigger & - done - exit 0 - elif echo "$@" | grep -qe '-h now'; then - for i in $(echo s u o); do - echo $i > /proc/sysrq-trigger & - done - exit 0 - fi + nohup ${PLUGINDIR}/sysrqshutdown.sh $@ 2>/dev/null & fi -# else use orig shutdown -shutdown.slxorig $@ exit 0 diff --git a/src/os-plugins/plugins/sysrqshutdown/files/sysrqshutdown.sh b/src/os-plugins/plugins/sysrqshutdown/files/sysrqshutdown.sh new file mode 100644 index 00000000..7e575ed3 --- /dev/null +++ b/src/os-plugins/plugins/sysrqshutdown/files/sysrqshutdown.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2010 - RZ Uni FR +# Copyright (c) 2010 - 2012 OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# sysrqshutdown.sh +# - Script for SYSRQ shutdown +################################################################################ + +# check if reboot or halt, else use orig shutdown +if echo "$@" | grep -qe '-r now' + then + echo "Rebooting $(hostname) (sysrq)!" + rq_opt="b" +elif echo "$@" | grep -qe '-h now' + then + echo "Shutting down $(hostname) (sysrq)!" + rq_opt="o" +else + shutdown.slxorig $@ & + exit 0 +fi + +echo s >/proc/sysrq-trigger +sleep 1 +echo u >/proc/sysrq-trigger +(sleep 3 >/dev/null; echo ${rq_opt} >/proc/sysrq-trigger) & +killall sshd >/dev/null 2>&1 + +exit 0 + |