3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
20 test -e "$UTIL_VSERVER_VARS" || {
21 echo "Can not find util-vserver installation; aborting..."
24 . "$UTIL_VSERVER_VARS"
25 . "$PKGLIBDIR/functions"
27 tmp=$(getopt -o d:r: --long force,dir:,pkgcfg:,hostname:,iproot:,iprootmask:,iprootbcast:,iprootdev:,help,version \
28 -n "$0" -- "$@") || exit 1
47 mknod -m$6 $1/$2 $3 $4 $5
50 function installBasePackages
55 test "$dir" != / || return
56 for filelist in "$dir"/*; do
57 test -e "$filelist" || continue
63 while test "$#" -gt 0; do
65 --reinstall) flags='--reinstall';;
66 --can-fail) can_fail=true;;
71 "$_VAPT_GET" "$name" -- install $flags "$@" || $can_fail
77 -d) distrib="$2"; shift 2;;
78 -r) root="$2"; shift 2;;
79 --pkgcfg) pkgcfg="$2"; shift 2;;
80 --force) force=1; shift;;
81 --dir) dir="$2"; shift 2;;
82 --hostname) hostname="$2"; shift 2;;
83 --iproot) iproot="$2"; shift 2;;
84 --iprootmask) iprootmask="$2"; shift 2;;
85 --iprootbcast) iprootbcast="$2"; shift 2;;
86 --iprootdev) iprootdev="$2"; shift 2;;
87 --help) showHelp; exit 0;;
88 --version) showVersion; exit 0;;
90 *) echo "Internal error!"; exit 1;;
95 echo "No vserver name given" >&2
100 echo "Too much parameters" >&2
105 test "$dir" || dir=$name
106 test "$pkgcfg" || pkgcfg=$root/.pkg/$name
109 test ! -d "$vdir" || {
110 test "$force" && mv "$vdir" "$vdir".bak
113 confdir="$CONFDIR/$name"
114 test ! -d "$confdir" || {
115 test "$force" && mv "$confdir" "$confdir".bak
118 test ! -d "$vdir" -a ! -d "$confdir" || {
119 echo "vserver-topdirectory and/or configuration exist already; "
120 echo "please try to use '--force', or remove them manually"
125 if test -e /etc/redhat-release; then
126 set -- $(cat /etc/redhat-release)
129 echo "Can not determine distribution; please specify it manually"
130 echo "with the '-d' option"
135 findFile INITPRE $CONFDIR/.distributions/$distrib/initpre $DISTRIBDIR/$distrib/initpre ""
136 findFile INITPOST $CONFDIR/.distributions/$distrib/initpost $DISTRIBDIR/$distrib/initpost ""
137 findFile DEVDESCR $CONFDIR/.distributions/$distrib/devs $DISTRIBDIR/$distrib/devs $DISTRIBDIR/defaults/devs
138 findDir APTTMPL $CONFDIR/.distributions/$distrib/apt $DISTRIBDIR/$distrib/apt
139 findDir RPMTMPL $CONFDIR/.distributions/$distrib/rpm $DISTRIBDIR/$distrib/rpm $DISTRIBDIR/defaults/rpm
140 findDir EXECDIR $CONFDIR/.distributions/$distrib/execdir $DISTRIBDIR/$distrib/execdir /
141 findDir RPMLIB $CONFDIR/.distributions/$distrib/rpmlib $DISTRIBDIR/$distrib/rpmlib /
142 findDir PKGDIR $CONFDIR/.distributions/$distrib/pkgs $DISTRIBDIR/$distrib/pkgs /
144 mkdir -p "$confdir"/apps/pkgmgmt "$vdir"/{dev,/var/lib/rpm,/etc} \
145 "$pkgcfg"/{rpm/{etc,state},apt/{etc,archives/partial,cache,state/lists/partial}}
148 makeInode "$vdir"/dev $spec
151 ln -s "$vdir" "$confdir"/vdir
152 for i in hostname iproot iprootmask iprootbcast iprootdev; do
155 test -z "$v" || echo $v >"$confdir/$i"
158 ln -s "$pkgcfg" "$confdir/apps/pkgmgmt/base"
159 test "$EXECDIR" = / || ln -s "$EXECDIR" "$confdir/apps/pkgmgmt/execdir"
160 test "$RPMLIB" = / || ln -s "$RPMLIB" "$confdir/apps/pkgmgmt/rpmlib"
162 cp -a "$RPMTMPL/"* "$pkgcfg/rpm/etc/"
163 cp -a "$APTTMPL/"* "$pkgcfg/apt/etc/"
166 test -z "$INITPRE" || "$INITPRE" "$name"
167 "$_VAPT_GET" "$name" -- update
168 installBasePackages "$name" "$PKGDIR"
169 "$_VAPT_GET" "$name" -- dist-upgrade
170 test -z "$INITPOST" || "$INITPOST" "$name"