]> git.pld-linux.org Git - packages/util-vserver.git/blob - vservers.init
- comment out superfluous symlink
[packages/util-vserver.git] / vservers.init
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
10 # Modified for PLD by Jan Rêkorajski <baggins@pld-linux.org>
11 # Distributed under the terms of the GNU General Public License v2
12 #
13
14 # Source function library
15 . /etc/rc.d/init.d/functions
16
17 [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
18 if [ ! -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
21 fi
22 . "$UTIL_VSERVER_VARS"
23
24 [ -f /etc/sysconfig/vservers ] && . /etc/sysconfig/vservers
25
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
41 case "$1" in
42 start)
43         if [ ! -f /var/lock/subsys/vprocunhide ]; then
44                 echo "Run \"/etc/rc.d/init.d/vprocunhide start\" first"
45                 exit 1
46         fi
47
48         if is_yes "$STARTALL"; then
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
73
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
86         ;;
87 stop)
88         for VSERVER in $START_VSERVERS; do
89                 if [ ! -f /var/lock/subsys/vserver-$VSERVER ]; then
90                         echo "Vserver '$VSERVER' is not running"
91                         continue
92                 fi
93                 show "Stopping single vserver '$VSERVER'"
94                 busy
95                 $_VSERVER $VSERVER stop
96                 _tellResult $?
97                 rc=$?
98                 rm -f /var/lock/subsys/vserver-$VSERVER
99         done
100
101         if is_yes "$STARTALL"; then
102                 if [ -f /var/lock/subsys/vservers-all ]; then
103                         show "Stopping all types of vservers"
104                         busy
105                         $_START_VSERVERS -j $NUMPARALLEL --all --stop
106                         _tellResult $?
107                         rc=$?
108                         rm -f /var/lock/subsys/vservers-all
109                 else
110                         echo "All types of vservers are not running"
111                 fi
112         else
113                 for MARK in $MARKS; do
114                         if [ ! -f /var/lock/subsys/vservers-$MARK ]; then
115                                 echo "Vservers of type '$MARK' are not running"
116                                 continue
117                         fi
118                         show "Stopping vservers of type '$MARK'"
119                         busy
120                         $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --stop
121                         _tellResult $?
122                         rc=$?
123                         rm -f /var/lock/subsys/vservers-$MARK
124                 done
125         fi
126         ;;
127 status)
128         echo "The following types of vservers are running:"
129
130         for i in /var/lock/subsys/vservers-*; do
131                 [ -f "$i" ] || continue
132                 echo $i | awk '{gsub("/var/lock/subsys/vservers-",""); printf(" %s\n",$0); }'
133                 running="true"
134         done
135
136         if [[ "${running}" != "true" ]]; then
137                 echo "  none"
138         fi
139
140         echo
141         echo "/proc/virtual/ says these are running:"
142
143         for i in /proc/virtual/*; do
144                 [ -d $i ] || continue
145                 NAME=$( basename $( vuname -g --xid $( basename ${i} ) CONTEX ) )
146                 echo "  ${NAME}"
147         done
148
149         echo
150         echo "vserver-stat says these are running:"
151         /usr/sbin/vserver-stat
152         ;;
153 *)
154         echo "Usage: $0 {start|stop|status}"
155         exit 1
156         ;;
157 esac
158
159 exit $RETVAL
160
161 # This must be last line !
162 # vi:syntax=sh
This page took 0.04365 seconds and 3 git commands to generate.