- getDistribution(): added sanity checks to make sure that there exist
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 25 Jul 2005 15:45:59 +0000 (15:45 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 25 Jul 2005 15:45:59 +0000 (15:45 +0000)
  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

util-vserver/scripts/vserver-build.functions

index 5c6a2aa..18c3c85 100644 (file)
@@ -113,37 +113,46 @@ function _renameVserverCfg
 }
 
 
-## Usage: getDistribution [<default>]
+## Usage: getDistribution [<default>] [<ignore-config>]
 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