#! /bin/bash # Copyright (C) 2005 Herbert Pötzl # based on vserver-build from Enrico Scholz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} test -e "$UTIL_VSERVER_VARS" || { echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 exit 1 } . "$UTIL_VSERVER_VARS" . "$_LIB_FUNCTIONS" . "$_LIB_VSERVER_SETUP_FUNCTIONS" . "$_LIB_VSERVER_BUILD_FUNCTIONS" ### Some local functions function showHelp() { echo \ $"Usage: $(basename $0) -n --force Options: --force ... destroy existing vservers with force Please report bugs to $PACKAGE_BUGREPORT" exit 0 } function showVersion() { echo \ $"vserver-destroy $PACKAGE_VERSION -- destroys a vserver This program is part of $PACKAGE_STRING Copyright (C) 2005 Herbert Pötzl This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty." exit 0 } ### main starts here set -e declare -a default_opts=() test -n "$NO_DEFAULT_OPTS" || getFileArray default_opts "$__CONFDIR/.defaults/apps/build/options" || : tmp=$(getopt -o +m:n: --long force,debug,help,version,$SETUP_OPTIONS -n "$(basename $0)" -- \ "${default_opts[@]}" "$@") || exit 1 eval set -- "$tmp" VSERVER_NAME= OPTION_FORCE= OPTION_DEBUG=0 while true; do case "$1" in (--help) showHelp $0 ;; (--version) showVersion ;; (--force) OPTION_FORCE=1;; (--debug) let ++OPTION_DEBUG; set -x;; (-n) VSERVER_NAME=$2; shift;; (--) shift; break;; (*) { setup_setOption2 "$1" "$2" && shift; } || \ panic $"vserver-destroy: internal error." ;; esac shift done test -n "$VSERVER_NAME" || panic $"Name of vserver not specified" setup_setDefaults "$VSERVER_NAME"