summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/sysrqshutdown/files/shutdown
blob: a27481d7f30587fa6f0c67b6c165d364f57410c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# -----------------------------------------------------------------------------
# Copyright (c) 2010 - RZ Uni FR
# Copyright (c) 2010 - 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/
# -----------------------------------------------------------------------------
# shutdown
#    - Script for SYSRQ shutdown
################################################################################

. /etc/opt/openslx/openslx.conf

################################################################################
### Define default dirs / get configs
################################################################################

PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins
PLUGINCONFVMGRID=${PLUGINCONFROOT}/sysrqshutdown
# include general configuration from vmgrid
if [ -f ${PLUGINCONFVMGRID}/sysrqshutdown.conf ]; then
  . ${PLUGINCONFVMGRID}/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
fi
# else use orig shutdown
shutdown.slxorig $@

exit 0