]>
Commit | Line | Data |
---|---|---|
6faf1615 JR |
1 | #!/bin/sh |
2 | # | |
3 | # util-vserver: sets the path to vshelper and kills all guest processes | |
4 | # | |
5 | # chkconfig: 2345 10 99 | |
6 | # description: Sets the path to vshelper and kills all guest processes | |
7 | ||
8 | # Source function library | |
9 | . /etc/rc.d/init.d/functions | |
10 | ||
11 | [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars | |
12 | if [ ! -e "$UTIL_VSERVER_VARS" ] ; then | |
13 | echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 | |
14 | exit 1 | |
15 | fi | |
16 | . "$UTIL_VSERVER_VARS" | |
17 | ||
18 | start() | |
19 | { | |
20 | show "Setting path to vshelper" | |
21 | if [ -e /proc/sys/kernel/vshelper ]; then | |
22 | echo "$_VSHELPER" >/proc/sys/kernel/vshelper | |
23 | ok | |
24 | else | |
25 | fail | |
26 | fi | |
27 | run_cmd "Loading default device map" $__PKGLIBDIR/bash-wrapper "handleDeviceMap --set 0 $__CONFDIR/.defaults/apps/vdevmap" | |
28 | } | |
29 | ||
30 | # Stop all running, but non-default guests" | |
31 | stop() | |
32 | { | |
33 | run_cmd "Stopping all running guests" $_START_VSERVERS -j 1 --all --stop | |
34 | ||
621740e0 | 35 | xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) |
6faf1615 JR |
36 | if [ -n "$xids" ]; then |
37 | show "Sending all contexts the TERM signal" | |
38 | for xid in $xids; do | |
39 | $_VATTRIBUTE --xid $xid --set --flag ~persistent | |
40 | $_VKILL --xid $xid -s 15 | |
41 | done | |
621740e0 | 42 | xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) |
6faf1615 JR |
43 | if [ -n "$xids" ]; then |
44 | fail | |
45 | else | |
46 | ok | |
47 | fi | |
48 | fi | |
49 | if [ -n "$xids" ]; then | |
50 | sleep 5 | |
51 | show "Sending all contexts the KILL signal" | |
52 | for xid in $xids; do | |
53 | $_VATTRIBUTE --xid $xid --set --flag ~persistent | |
54 | $_VKILL --xid $xid -s 9 | |
55 | done | |
621740e0 | 56 | xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) |
6faf1615 JR |
57 | if [ -n "$xids" ]; then |
58 | fail | |
59 | else | |
60 | ok | |
61 | fi | |
62 | fi | |
63 | } | |
64 | ||
65 | RETVAL=0 | |
66 | # See how we were called. | |
67 | case "$1" in | |
68 | start) | |
69 | start | |
70 | ;; | |
71 | stop) | |
72 | stop | |
73 | ;; | |
74 | restart) | |
75 | stop | |
76 | start | |
77 | ;; | |
78 | reload|force-reload) | |
79 | start | |
80 | [ $? -ne 0 ] && RETVAL=7 | |
81 | ;; | |
82 | status) | |
83 | if [ -e /proc/sys/kernel/vshelper ]; then | |
84 | read _vsh </proc/sys/kernel/vshelper | |
85 | show "Path to vshelper: $_vsh, expected: $_VSHELPER" | |
86 | if [ "$_vsh" = "$_VSHELPER" ]; then | |
87 | ok | |
88 | RETVAL=0 | |
89 | else | |
90 | fail | |
91 | RETVAL=1 | |
92 | fi | |
93 | else | |
94 | RETVAL=1 | |
95 | fi | |
96 | ;; | |
97 | *) | |
98 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" | |
99 | exit 3 | |
100 | ;; | |
101 | esac | |
102 | ||
103 | exit $RETVAL |