]> git.pld-linux.org Git - packages/util-vserver.git/blame - vservers.init
- suggest/require crondaemon
[packages/util-vserver.git] / vservers.init
CommitLineData
01710ec9
JR
1#!/bin/sh
2#
3# vservers: starts and stops vservers
4#
5# chkconfig: 345 98 02
6# description: Wrapper to start and stop vservers
7# This script does not care for vservers not started by it
8#
9# Copyright 1999-2004 Gentoo Foundation
8738fdcb 10# Modified for PLD by Jan Rękorajski <baggins@pld-linux.org>
01710ec9 11# Distributed under the terms of the GNU General Public License v2
5deda8db
ER
12#
13
14# Source function library
15. /etc/rc.d/init.d/functions
01710ec9 16
99e1c7ab 17[ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/share/util-vserver/util-vserver-vars
01710ec9
JR
18if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
19 echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
20 exit 1
21fi
22. "$UTIL_VSERVER_VARS"
23
24[ -f /etc/sysconfig/vservers ] && . /etc/sysconfig/vservers
25
01710ec9
JR
26[ -n "$NUMPARALLEL" ] || NUMPARALLEL=1
27[ -n "$LOCKDIR" ] || LOCKDIR="/var/lock/vservers"
28
29_tellResult()
30{
31 local rc=$1
32 deltext
33 case "$rc" in
34 0) ok;;
35 2) ok; rc=0;;
36 *) fail;;
37 esac
38 return $rc
39}
40
41case "$1" in
42start)
43 if [ ! -f /var/lock/subsys/vprocunhide ]; then
e10ad57e 44 echo "Run \"/sbin/service vprocunhide start\" first"
01710ec9
JR
45 exit 1
46 fi
47
02c249c3 48 if is_yes "$STARTALL"; then
01710ec9
JR
49 if [ ! -f /var/lock/subsys/vservers-all ]; then
50 show "Starting all types of vservers"
51 busy
52 $_START_VSERVERS -j $NUMPARALLEL --all --start
53 _tellResult $?
54 rc=$?
55 [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-all
56 else
57 echo "All types of vservers are already startred"
58 fi
59 else
60 for MARK in $MARKS; do
61 if [ -f /var/lock/subsys/vservers-$MARK ]; then
62 echo "Vservers of type '$MARK' are already startred"
63 continue
64 fi
65 show "Starting vservers of type '$MARK'"
66 busy
67 $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --start
68 _tellResult $?
69 rc=$?
70 [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-$MARK
71 done
72 fi
5deda8db 73
01710ec9
JR
74 for VSERVER in $START_VSERVERS; do
75 if [ -f /var/lock/subsys/vserver-$VSERVER ]; then
76 echo "Vserver '$VSERVER' is already startred"
77 continue
78 fi
79 show "Starting single vserver '$VSERVER'"
80 busy
81 $_VSERVER $VSERVER start
82 _tellResult $?
83 rc=$?
84 [ $rc -eq 0 ] && touch /var/lock/subsys/vserver-$VSERVER
85 done
9143b206 86 touch /var/lock/subsys/vservers
01710ec9
JR
87 ;;
88stop)
86a844ee
JR
89 __STOP_VSERVERS=
90 for __V in $START_VSERVERS; do
91 __STOP_VSERVERS="$__V $__STOP_VSERVERS"
92 done
93 for VSERVER in $__STOP_VSERVERS; do
01710ec9
JR
94 if [ ! -f /var/lock/subsys/vserver-$VSERVER ]; then
95 echo "Vserver '$VSERVER' is not running"
96 continue
97 fi
98 show "Stopping single vserver '$VSERVER'"
99 busy
100 $_VSERVER $VSERVER stop
101 _tellResult $?
102 rc=$?
103 rm -f /var/lock/subsys/vserver-$VSERVER
104 done
105
02c249c3 106 if is_yes "$STARTALL"; then
01710ec9
JR
107 if [ -f /var/lock/subsys/vservers-all ]; then
108 show "Stopping all types of vservers"
109 busy
110 $_START_VSERVERS -j $NUMPARALLEL --all --stop
111 _tellResult $?
112 rc=$?
113 rm -f /var/lock/subsys/vservers-all
114 else
115 echo "All types of vservers are not running"
116 fi
117 else
86a844ee
JR
118 __STOP_MARKS=
119 for __V in $MARKS; do
120 __STOP_MARKS="$__V $__STOP_MARKS"
121 done
122 for MARK in $__STOP_MARKS; do
01710ec9
JR
123 if [ ! -f /var/lock/subsys/vservers-$MARK ]; then
124 echo "Vservers of type '$MARK' are not running"
125 continue
126 fi
127 show "Stopping vservers of type '$MARK'"
128 busy
129 $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --stop
130 _tellResult $?
131 rc=$?
132 rm -f /var/lock/subsys/vservers-$MARK
133 done
134 fi
d1b3381f 135 rm -f /var/lock/subsys/vservers
01710ec9
JR
136 ;;
137status)
138 echo "The following types of vservers are running:"
5deda8db 139
01710ec9
JR
140 for i in /var/lock/subsys/vservers-*; do
141 [ -f "$i" ] || continue
142 echo $i | awk '{gsub("/var/lock/subsys/vservers-",""); printf(" %s\n",$0); }'
02c249c3 143 running="true"
01710ec9 144 done
5deda8db 145
01710ec9
JR
146 if [[ "${running}" != "true" ]]; then
147 echo " none"
148 fi
5deda8db 149
01710ec9
JR
150 echo
151 echo "/proc/virtual/ says these are running:"
5deda8db 152
01710ec9
JR
153 for i in /proc/virtual/*; do
154 [ -d $i ] || continue
155 NAME=$( basename $( vuname -g --xid $( basename ${i} ) CONTEX ) )
156 echo " ${NAME}"
157 done
5deda8db 158
01710ec9
JR
159 echo
160 echo "vserver-stat says these are running:"
161 /usr/sbin/vserver-stat
162 ;;
163*)
e10ad57e
ER
164 msg_usage "$0 {start|stop|status}"
165 exit 3
01710ec9
JR
166 ;;
167esac
168
169exit $RETVAL
170
171# This must be last line !
172# vi:syntax=sh
This page took 0.087809 seconds and 4 git commands to generate.