- fixed some statements which would fail with 'set -e'
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 3 Nov 2003 19:37:38 +0000 (19:37 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 3 Nov 2003 19:37:38 +0000 (19:37 +0000)
- made 'disableInterface' smart so that it calculates parameters
  automatically

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@349 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/vserver.functions

index 111d23a..7c74f46 100644 (file)
@@ -37,6 +37,7 @@ declare -a INITKILL_SEQ=()
 declare -a ENTER_SHELL=()
 
 INTERFACE_CMDS_IDX=0
+_HAVE_INTERFACE_OPTIONS=
 
 INITSTYLE=sysv
 
@@ -225,9 +226,9 @@ function _generateChcontextOptions
     local flag
 
     {
-       read ctx        <"$vdir"/context
-       read hostname   <"$vdir"/hostname
-       read domainname <"$vdir"/domainname
+       read ctx        <"$vdir"/context     || :
+       read hostname   <"$vdir"/hostname    || :
+       read domainname <"$vdir"/domainname  || :
     } 2>/dev/null
 
     test -z "$S_CONTEXT" || ctx=$S_CONTEXT
@@ -340,6 +341,7 @@ function _generateInterfaceOptions
     
         _processSingleInterface "$iface"
     done
+    _HAVE_INTERFACE_OPTIONS=1
 }
 
 function enableInterfaces
@@ -366,11 +368,13 @@ function enableInterfaces
 
 function disableInterfaces
 {
+    test "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
+
     local i=$INTERFACE_CMDS_IDX
     declare -a var
 
     while test $i -gt 0; do
-       let --i
+       let --i || :
 
        eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
        local type=${var[0]}