SOURCES: vservers.init (NEW), vservers.sysconfig (NEW) - gentoo-ba...
baggins
baggins at pld-linux.org
Fri Nov 4 20:05:50 CET 2005
Author: baggins Date: Fri Nov 4 19:05:50 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- gentoo-based init script and config for starting vservers
---- Files affected:
SOURCES:
vservers.init (NONE -> 1.1) (NEW), vservers.sysconfig (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/vservers.init
diff -u /dev/null SOURCES/vservers.init:1.1
--- /dev/null Fri Nov 4 20:05:50 2005
+++ SOURCES/vservers.init Fri Nov 4 20:05:45 2005
@@ -0,0 +1,160 @@
+#!/bin/sh
+#
+# vservers: starts and stops vservers
+#
+# chkconfig: 345 98 02
+# description: Wrapper to start and stop vservers
+# This script does not care for vservers not started by it
+#
+# Copyright 1999-2004 Gentoo Foundation
+# Modified for PLD by Jan Rękorajski <baggins at pld-linux.org>
+# Distributed under the terms of the GNU General Public License v2
+#
+
+[ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
+if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
+ echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
+ exit 1
+fi
+. "$UTIL_VSERVER_VARS"
+
+[ -f /etc/sysconfig/vservers ] && . /etc/sysconfig/vservers
+
+[ -n "$MARKS" ] || MARKS="default"
+[ -n "$NUMPARALLEL" ] || NUMPARALLEL=1
+[ -n "$LOCKDIR" ] || LOCKDIR="/var/lock/vservers"
+
+_tellResult()
+{
+ local rc=$1
+ deltext
+ case "$rc" in
+ 0) ok;;
+ 2) ok; rc=0;;
+ *) fail;;
+ esac
+ return $rc
+}
+
+case "$1" in
+start)
+ if [ ! -f /var/lock/subsys/vprocunhide ]; then
+ echo "Run \"/etc/rc.d/init.d/vprocunhide start\" first"
+ exit 1
+ fi
+
+ if [ is_yes "$STARTALL" ]; then
+ if [ ! -f /var/lock/subsys/vservers-all ]; then
+ show "Starting all types of vservers"
+ busy
+ $_START_VSERVERS -j $NUMPARALLEL --all --start
+ _tellResult $?
+ rc=$?
+ [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-all
+ else
+ echo "All types of vservers are already startred"
+ fi
+ else
+ for MARK in $MARKS; do
+ if [ -f /var/lock/subsys/vservers-$MARK ]; then
+ echo "Vservers of type '$MARK' are already startred"
+ continue
+ fi
+ show "Starting vservers of type '$MARK'"
+ busy
+ $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --start
+ _tellResult $?
+ rc=$?
+ [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-$MARK
+ done
+ fi
+
+ for VSERVER in $START_VSERVERS; do
+ if [ -f /var/lock/subsys/vserver-$VSERVER ]; then
+ echo "Vserver '$VSERVER' is already startred"
+ continue
+ fi
+ show "Starting single vserver '$VSERVER'"
+ busy
+ $_VSERVER $VSERVER start
+ _tellResult $?
+ rc=$?
+ [ $rc -eq 0 ] && touch /var/lock/subsys/vserver-$VSERVER
+ done
+ ;;
+stop)
+ for VSERVER in $START_VSERVERS; do
+ if [ ! -f /var/lock/subsys/vserver-$VSERVER ]; then
+ echo "Vserver '$VSERVER' is not running"
+ continue
+ fi
+ show "Stopping single vserver '$VSERVER'"
+ busy
+ $_VSERVER $VSERVER stop
+ _tellResult $?
+ rc=$?
+ rm -f /var/lock/subsys/vserver-$VSERVER
+ done
+
+ if [ is_yes "$STARTALL" ]; then
+ if [ -f /var/lock/subsys/vservers-all ]; then
+ show "Stopping all types of vservers"
+ busy
+ $_START_VSERVERS -j $NUMPARALLEL --all --stop
+ _tellResult $?
+ rc=$?
+ rm -f /var/lock/subsys/vservers-all
+ else
+ echo "All types of vservers are not running"
+ fi
+ else
+ for MARK in $MARKS; do
+ if [ ! -f /var/lock/subsys/vservers-$MARK ]; then
+ echo "Vservers of type '$MARK' are not running"
+ continue
+ fi
+ show "Stopping vservers of type '$MARK'"
+ busy
+ $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --stop
+ _tellResult $?
+ rc=$?
+ rm -f /var/lock/subsys/vservers-$MARK
+ done
+ fi
+ ;;
+status)
+ echo "The following types of vservers are running:"
+
+ for i in /var/lock/subsys/vservers-*; do
+ [ -f "$i" ] || continue
+ echo $i | awk '{gsub("/var/lock/subsys/vservers-",""); printf(" %s\n",$0); }'
+ local running="true"
+ done
+
+ if [[ "${running}" != "true" ]]; then
+ echo " none"
+ fi
+
+ echo
+ echo "/proc/virtual/ says these are running:"
+
+ for i in /proc/virtual/*; do
+ [ -d $i ] || continue
+ NAME=$( basename $( vuname -g --xid $( basename ${i} ) CONTEX ) )
+ echo " ${NAME}"
+ done
+
+ echo
+ echo "vserver-stat says these are running:"
+ /usr/sbin/vserver-stat
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+exit $RETVAL
+
+# This must be last line !
+# vi:syntax=sh
================================================================
Index: SOURCES/vservers.sysconfig
diff -u /dev/null SOURCES/vservers.sysconfig:1.1
--- /dev/null Fri Nov 4 20:05:50 2005
+++ SOURCES/vservers.sysconfig Fri Nov 4 20:05:45 2005
@@ -0,0 +1,31 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# A space-delimited list of vserver MARKS to start.
+# Identification of vservers happens by
+# putting the flavor into /etc/vservers/<vserver-id>/apps/init/mark.
+# Note: on stop the init script will stop ALL running vservers
+MARKS="default"
+
+# A space-delimited list of vservers to start
+# This can be used together with MARKS or as a replacement
+# Note: on stop the init script will stop ALL running vservers
+#START_VSERVERS=""
+
+# Wether to start all vserver MARKS by default (supersedes MARKS)
+# This will be enabled if STARTALL is set regardless of its content
+# i.e. you have to comment to disable it
+# Note: on stop the init script will stop ALL running vservers
+#STARTALL=yes
+
+# Number of vservers which shall be started in parallel; since most
+# initmethods are spending much time in sleeps, it is safe to
+# use a high number here, though you should pay attention if you make
+# use of depends in /etc/vservers as some services may not be up if
+# started in parallel
+#NUMPARALLEL=6
+
+# The location of util-vserver-vars
+# This file contains variables to util-vserver scripts used within the
+# init script. Change at your own risk.
+#UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
================================================================
More information about the pld-cvs-commit
mailing list