mount filesystems on 'vserver ... pkgmgmt ...' operations
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 20 May 2004 00:38:08 +0000 (00:38 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 20 May 2004 00:38:08 +0000 (00:38 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1570 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/pkgmgmt
util-vserver/scripts/vserver

index a641dfb..dc58391 100755 (executable)
@@ -24,6 +24,7 @@ test -e "$UTIL_VSERVER_VARS" || {
 . "$UTIL_VSERVER_VARS"
 . "$_LIB_FUNCTIONS"
 . "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
+. "$PKGLIBDIR/vserver.functions"
 
 function showHelp()
 {
@@ -120,6 +121,45 @@ function _unhashAuto()
     rm -f $tmp
 }
 
+function _mountFilesystemsInternal()
+{
+    local fstab="$1"
+    test -e "$fstab" || return 0
+    shift
+    
+    "$@" $_SECURE_MOUNT -n -a --chroot "$vdir" --fstab "$fstab"
+}
+
+function _mountFilesystems()
+{
+    local cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
+       echo "Can not determine configuration directory for '$1'; ..." >&2
+       return 1
+    }
+    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+    
+    _mountFilesystemsInternal "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || return 1
+    _mountFilesystemsInternal "$cfgdir"/fstab.local $_CHBIND "${CHBIND_OPTS[@]}" || return 1
+}
+
+function _umountFilesystems()
+{
+    local cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
+       echo "Can not determine configuration directory for '$1'; ..." >&2
+       return 1
+    }
+    local vdir=$cfgdir/vdir
+    local is_ok=1
+    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+
+    pushd "$vdir/" >/dev/null || return 1
+       _umountVserverInternal  "$cfgdir"/fstab.local                              || is_ok=
+       _umountVserverInternal  "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
+    popd >/dev/null           || return 1
+    
+    test "$is_ok"
+}
+
 function processVserver_RH()
 {
     local vserver=$1
@@ -290,6 +330,7 @@ function processVserver()
     test -z "$skip" || return 1
 
     local style
+    _mountFilesystems  "$vserver"       || return 1
     pkgmgmt.guessStyle "$vserver" style || return 1
 
     case "$style" in
@@ -299,6 +340,8 @@ function processVserver()
            echo $"Vserver style '$style' is not supported for packagemanagment" >&2
            return 1
     esac
+
+    _umountFilesystems "$vserver"       || return 1
 }
 
 tmp=$(getopt -o y --long debug,externalize,internalize,help,version -n "$0" -- "$@") || exit 1
index de19cd0..ef887f7 100755 (executable)
@@ -235,7 +235,7 @@ case "$2" in
     (pkgmgmt)
        op=$3
        shift 3
-       exec $_PKGMGMT ${op:+--$op} "$@" -- "$vserver"
+       exec $_VNAMESPACE --new -- $_PKGMGMT ${op:+--$op} "$@" -- "$vserver"
        ;;
 
     (apt-get|apt-config|apt-cache)