3 # util-vserver sets the path to vshelper and kills all guest processes
5 # chkconfig: 2345 10 90
6 # description: Sets the path to vshelper and kills all guest processes
9 # Provides: util-vserver
10 # Required-Start: $remote_fs $syslog $time
11 # Required-Stop: $remote_fs $syslog $time
12 # Default-Start: 2 3 4 5
14 # Short-Description: Sets the path to vshelper and kills all guest processes
15 # Description: Sets the path to vshelper and kills all guest processes
18 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
19 test -e "$UTIL_VSERVER_VARS" || {
20 echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
23 . "$UTIL_VSERVER_VARS"
26 . "$_LIB_VSERVER_INIT_FUNCTIONS"
28 . "$__PKGLIBDIR/vserver.functions"
33 local f="/proc/sys/kernel/vshelper"
35 echo "$_VSHELPER" > "$f"
42 function kill_contexts()
45 for xid in `ls -1 /proc/virtual 2>/dev/null`; do
46 [ "$xid" = "info" -o "$xid" = "status" ] && continue
47 $_VATTRIBUTE --xid $xid --set --flag ~persistent
48 $_VKILL --xid $xid -s 15
50 $_VKILL --xid $xid -s 9
53 for xid in `ls -1 /proc/virtual 2>/dev/null`; do
54 [ "$xid" = "info" -o "$xid" = "status" ] && continue
60 function create_dirs()
62 $_MKDIR -p "$__RUNDIR" && $_MKDIR -p "$__VSHELPERSTATEDIR" && $_MKDIR -p `$_READLINK "$__PKGSTATEREVDIR"`
65 function mount_cgroup()
67 _generateCgroupOptions
68 test -n "$CGROUP_MNT" || return 0
69 $_MKDIR -p "$CGROUP_MNT"
70 $_MOUNT -t cgroup -o "$CGROUP_SUBSYS" vserver "$CGROUP_MNT"
73 function umount_cgroup()
75 _generateCgroupOptions
76 test -n "$CGROUP_MNT" || return 0
77 $_UMOUNT "$CGROUP_MNT"
82 _beginResult $"Creating required directories"
85 _beginResult $"Setting path to vshelper"
89 _beginResult $"Loading default device map"
90 handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap"
93 _beginResult $"Mounting cgroup-hierarchy"
97 test "$retval" -ne 0 || touch "$lockfile"
103 # Stop all running, but non-default guests"
104 _beginResult $"Stopping all running guests"
105 $_START_VSERVERS -j 1 --all --stop
107 _beginResult $"Killing all running contexts"
112 _beginResult $"Unmounting cgroup-hierarchy"
127 start|stop|restart) $1;;
130 test -f $lockfile && restart || :
133 test -f $lockfile && {
134 echo $"Path to vshelper has been set"
137 echo $"Path to vshelper has not been set"
141 echo "Usage: $0 {start|stop|reload|restart|condrestart|status}"