util-vserver (2247B)
1 #!/bin/bash 2 # 3 # util-vserver sets the path to vshelper and kills all guest processes 4 # 5 # chkconfig: 2345 10 90 6 # description: Sets the path to vshelper and kills all guest processes 7 # 8 ### BEGIN INIT INFO 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 13 # Default-Stop: 0 1 6 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 16 ### END INIT INFO 17 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 21 exit 1 22 } 23 . "$UTIL_VSERVER_VARS" 24 25 LOCKFILE=util-vserver 26 . "$_LIB_VSERVER_INIT_FUNCTIONS" 27 . "$_LIB_FUNCTIONS" 28 . "$_LIB_VSERVER_FUNCTIONS" 29 30 function start() 31 { 32 _beginResult $"Creating required directories" 33 create_dirs 34 _endResult $? 35 _beginResult $"Setting path to vshelper" 36 set_helper 37 _endResult $? 38 local retval=$? 39 _beginResult $"Loading default device map" 40 handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap" 41 _endResult $? 42 if hasCgroup; then 43 _beginResult $"Mounting cgroup-hierarchy" 44 mount_cgroup 45 _endResult $? 46 fi 47 test "$retval" -ne 0 || touch "$lockfile" 48 return $retval 49 } 50 51 function stop() 52 { 53 # Stop all running, but non-default guests" 54 _beginResult $"Stopping all running guests" 55 $_START_VSERVERS -j 1 --all --stop 56 _endResult $? 57 _beginResult $"Killing all running contexts" 58 kill_contexts 59 _endResult $? 60 local retval=$? 61 if hasCgroup; then 62 _beginResult $"Unmounting cgroup-hierarchy" 63 umount_cgroup 64 _endResult $? 65 fi 66 $_RM -f "$lockfile" 67 return $retval 68 } 69 70 function restart() 71 { 72 stop 73 start 74 } 75 76 case "$1" in 77 start|stop|restart) $1;; 78 reload) ;; 79 condrestart) 80 test -f $lockfile && restart || : 81 ;; 82 status) 83 test -f $lockfile && { 84 echo $"Path to vshelper has been set" 85 exit 0 86 } 87 echo $"Path to vshelper has not been set" 88 exit 1 89 ;; 90 *) 91 echo "Usage: $0 {start|stop|reload|restart|condrestart|status}" 92 exit 2 93 ;; 94 esac