From: Enrico Scholz Date: Mon, 25 Jul 2005 15:45:59 +0000 (+0000) Subject: - getDistribution(): added sanity checks to make sure that there exist X-Git-Tag: version_0_30_210~116 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35d5f9538dabb3735a19430577adc0c3468e696b;p=util-vserver.git - getDistribution(): added sanity checks to make sure that there exist a configuration for the selected distribution - base.initFilesystem(): allow empty directories as root directories for new vservers; this uses the new isDirectoryEmpty() function - base.__cleanup(): armed the cleanup code; formerly there was still the safety 'echo' giving out the resulting command instead of executing it git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2165 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/vserver-build.functions b/util-vserver/scripts/vserver-build.functions index 5c6a2aa..18c3c85 100644 --- a/util-vserver/scripts/vserver-build.functions +++ b/util-vserver/scripts/vserver-build.functions @@ -113,37 +113,46 @@ function _renameVserverCfg } -## Usage: getDistribution [] +## Usage: getDistribution [] [] function getDistribution { - test -z "$DISTRIBUTION" || return 0 - - if test -e /etc/fedora-release; then - set -- $(cat /etc/fedora-release) - DISTRIBUTION=fdr$4 - elif test -e /etc/redhat-release; then - set -- $(cat /etc/redhat-release) - DISTRIBUTION=rh$5 - elif test -e /etc/debian_version; then - set -- $(cat /etc/debian_version) - DISTRIBUTION=deb$1 - elif test -e /etc/SuSE-release; then - set -- $(cat /etc/SuSE-release) - DISTRIBUTION=suse$3 - elif test -e /etc/gentoo-release; then - set -- $(cat /etc/gentoo-release) - DISTRIBUTION=gentoo$5 - elif test -e /etc/slackware-release; then - set -- $(cat /etc/slackware-release) - DISTRIBUTION=slackware$2 - elif test -n "$1"; then - DISTRIBUTION=$1 - else - echo \ -"Can not determine distribution; please specify it manually -with the '-d' option" >&2 - exit 1 - fi >&2 + local ignore_config=$2 + + if test -z "$DISTRIBUTION"; then + if test -e /etc/fedora-release; then + set -- $(cat /etc/fedora-release) + DISTRIBUTION=fdr$4 + elif test -e /etc/redhat-release; then + set -- $(cat /etc/redhat-release) + DISTRIBUTION=rh$5 + elif test -e /etc/debian_version; then + set -- $(cat /etc/debian_version) + DISTRIBUTION=deb$1 + elif test -e /etc/SuSE-release; then + set -- $(cat /etc/SuSE-release) + DISTRIBUTION=suse$3 + elif test -e /etc/gentoo-release; then + set -- $(cat /etc/gentoo-release) + DISTRIBUTION=gentoo$5 + elif test -e /etc/slackware-release; then + set -- $(cat /etc/slackware-release) + DISTRIBUTION=slackware$2 + elif test -n "$1"; then + DISTRIBUTION=$1 + else + colpanic $"\ +ERROR: Can not determine distribution; please specify it manually with + the '-d' option." + fi + fi + + test -n "$ignore_config" -o \ + -d "$__CONFDIR/.distributions/$DISTRIBUTION" -o \ + -d "$__DISTRIBDIR/$DISTRIBUTION" || + colpanic $"\ +ERROR: Can not find configuration for the distribution '$DISTRIBUTION'; + please read http://linux-vserver.org/HowToRegisterNewDistributions + for information how to add support for your own distribution." } function base._addGeneratedFile @@ -155,7 +164,7 @@ function base._addGeneratedFile function base.initFilesystem { test -z "$1" || _renameVserverCfg - test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || { + test isDirectoryEmpty "$VDIR" -a ! -e "$SETUP_CONFDIR" || { echo \ "vserver-topdirectory '$VDIR' and/or configuration at '$SETUP_CONFDIR' exist already; please try to use '--force', or remove them manually" @@ -203,7 +212,7 @@ function base.__cleanup test -z "$OPTION_KEEP" || return 0 test -z "$__BASE_SUCCESS" || return 0 - echo rm -rf "${__BASE_GENERATED_FILES[@]}" + rm -rf "${__BASE_GENERATED_FILES[@]}" } function base.init