X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fvserver;h=74709cc1c29419345741bfb3f8fd7099bb60db17;hb=d3e2621bf95b7378c166a5f1e7fd4f39bca5cfc2;hp=991c111aec559a4c977697b55effcd9b67b7694f;hpb=6f377550a2e5294b1d1f1ac9ce360ad5cff27e78;p=util-vserver.git diff --git a/util-vserver/scripts/vserver b/util-vserver/scripts/vserver index 991c111..74709cc 100755 --- a/util-vserver/scripts/vserver +++ b/util-vserver/scripts/vserver @@ -18,7 +18,7 @@ # set -e -: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars} +: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} test -e "$UTIL_VSERVER_VARS" || { echo "Can not find util-vserver installation; aborting..." exit 1 @@ -31,13 +31,16 @@ test -e "$UTIL_VSERVER_VARS" || { function showHelp() { echo \ -$"Usage: $(basename $0) [--] * +$"Usage: $(basename $0) [-s|--sync] [-v|--verbose] [--silent] + [--] * is the name of a vserver. Possible commands are: - start ... starts the specified vserver - stop ... stops the specified vserver + start [--nodeps] * + ... starts the specified vserver + stop [--nodeps] * + ... stops the specified vserver restart ... restarts the specified vserver; this is the subsequent execution of a synchronized 'stop' and a 'start' condrestart ... restarts the vserver when it is running already @@ -56,6 +59,28 @@ Possible commands are: build * ... builds a new vserver from scratch + unify [-R] + ... (de)unify vserver + + pkg install + ... installs package(s) in the vserver + + apt-get,apt-config,apt-cache * + ... execute the apt-* command for the given vserver + rpm * + ... execute the rpm command for the given vserver + + pkgmgmt externalize|internalize [-y] + ... externalize or internalize the package-management for the + given vserver. 'Externalize' means that package metadata + and management tools (apt-get,rpm) are living in the host, + while 'internalize' means that data and programs from the + vserver will be used. + + unify * + ... unify the vserver with its reference vserver(s). + + Please report bugs to $PACKAGE_BUGREPORT" exit 0 } @@ -72,28 +97,51 @@ the GNU General Public License. This program has absolutely no warranty." exit 0 } +function suexec() +{ + . $PKGLIBDIR/vserver.suexec +} + +function restart() +{ + "${SELF[@]}" --sync "$vserver" stop + exec "${SELF[@]}" "$vserver" start +} ### main starts here set +e -tmp=$(getopt -o + --long help,version -n "$0" -- "$@") || exit 1 +tmp=$(getopt -o +sv --long help,debug,version,sync,verbose,silent -n "$0" -- "$@") || exit 1 eval set -- "$tmp" +OPTION_FORCE_SYNC= +OPTION_VERBOSE= +OPTION_SILENT= +OPTION_DEBUG= + while true; do case "$1" in - --help) showHelp $0 ;; - --version) showVersion ;; - --) shift; break;; - *) echo $"vserver: internal error; arg=='$1'"; exit 1;; + --help) showHelp $0 ;; + --version) showVersion ;; + --debug) OPTION_DEBUG=$1; set -x; shift;; + -v|--verbose) OPTION_VERBOSE=$1; shift;; + -s|--sync) OPTION_FORCE_SYNC=$1; shift;; + --silent) OPTION_SILENT=$1; shift;; + --) shift; break;; + *) echo $"vserver: internal error; arg=='$1'"; exit 1;; esac done -test "$2" != build || { shift; exec "$_VSERVER_BUILD" "$@"; } +OPTION_ALL=( $OPTION_SILENT $OPTION_VERBOSE $OPTION_DEBUG ) +SELF=( "$0" "${OPTION_ALL[@]}" ) vserver=$1 cmd=$2 +test "$cmd" != build || { shift 2; exec "$_VSERVER_BUILD" -n "$vserver" "$@"; } + + allow_legacy= case "$vserver" in @@ -128,35 +176,55 @@ fi . $PKGLIBDIR/vserver.functions case "$2" in - start|stop|suexec) + start|stop) shift 2 . $PKGLIBDIR/vserver.$cmd ;; - restart) - "$0" "$1" stop - exec "$0" "$1" start + suexec|restart) + shift 2 + $cmd "$@" ;; condrestart) - test ! isVserverRunning "$VSERVER_DIR" || exec "$0" "$1" restart + test ! isVserverRunning "$VSERVER_DIR" || restart ;; exec) shift 2 - exec "$0" "$vserver" suexec root "$@" + suexec root "$@" ;; chkconfig) shift 2 - exec "$0" "$vserver" suexec root chkconfig "$@" + suexec root chkconfig "$@" ;; enter) getEnterShell "$VSERVER_DIR" - exec "$0" "$1" suexec root "${ENTER_SHELL[@]}" + suexec root "${ENTER_SHELL[@]}" ;; running) isVserverRunning "$VSERVER_DIR" ;; + + unify) + shift 2 + exec $_VUNIFY "$@" "$vserver" + ;; + + pkg) + shift 2 + exec $_VPKG "$vserver" "$@" + ;; + + apt-get|apt-config|apt-cache) + export _APT_GET=$2 + shift 2 + exec $_VAPT_GET -- "$@" + ;; + rpm) + exec $_VRPM -- "$@" + ;; + status) if getVserverStatus "$VSERVER_DIR" ctx procnum; then - echo $"Vserver '$1' is running at context '$ctx'" + echo $"Vserver '$vserver' is running at context '$ctx'" if test "$2" = status; then echo $"Number of processes:" $procnum @@ -165,7 +233,7 @@ case "$2" in fi exit 0 else - echo $"Vserver '$1' is not running" + echo $"Vserver '$vserver' is not running" exit 1 fi ;;