summaryrefslogblamecommitdiffstats
path: root/src/os-plugins/plugins/sysrqshutdown/files/sysrqshutdown.sh
blob: 7e575ed3472b9cce08d2a53da5a5ff8d9c8c32fa (plain) (tree)






































                                                                                
#!/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