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.
18 # Expected environment:
19 # $VSERVER_NAME ... name of vserver
39 c|b) mknod -m$6 "$dst" $3 $4 $5;;
40 d) mkdir -p -m$4 "$dst";;
44 *) echo "Unknown dev-entry mode '$3'" >&2
50 function populateDirectory
59 for file in "$i"/*; do
60 test -e "$file" || continue
62 */CVS) test ! -d "$file" || continue;;
63 *.rpmsave|*.rpmnew|*.rpmorig)
74 test -z "$ROOTDIR" || return 0
76 for item in "\"$CONFDIR/.defaults/vdirbase\" 1" "$DEFAULT_VSERVERDIR"; do
80 test ! -d "$ROOTDIR" || break
83 test -d "$ROOTDIR" || {
84 echo "Root-directory '$ROOTDIR' does not exist or is invalid"
89 function _setPkgCfgBase
91 test -z "$PKGCFGBASE" || return 0
93 for item in "\"$CONFDIR/.defaults/apps/pkgmgmt/base\" 1" "$ROOTDIR/.pkg" "$DEFAULT_VSERVERPKGDIR"; do
97 test ! -d "$PKGCFGBASE" || break
100 test -d "$PKGCFGBASE" || {
101 echo "pkgcfgbase-dir '$PKGCFGBASE' does not exists or is invalid"
110 test -z "$PKGCFGDIR" || return 0
111 PKGCFGDIR="$PKGCFGBASE/$VSERVERDIRNAME"
114 function _setVserverDir
116 test -z "$VSERVERDIRNAME" || return 0
117 VSERVERDIRNAME="$VSERVER_NAME"
122 VDIR="$ROOTDIR/$VSERVERDIRNAME"
127 test -z "$OPTION_SILENT" || return 0
131 function _renameVserverCfg
133 local suffix=.~$(date +'%s')~
136 for i in "$VDIR" "$SETUP_CONFDIR"; do
139 say "Renamed '$i' to '$i$suffix'"
144 function getDistribution
146 test -z "$DISTRIBUTION" || return 0
148 if test -e /etc/fedora-release; then
149 set -- $(cat /etc/fedora-release)
151 elif test -e /etc/redhat-release; then
152 set -- $(cat /etc/redhat-release)
154 elif test -e /etc/debian_version; then
155 set -- $(cat /etc/debian_version)
158 echo "Can not determine distribution; please specify it manually"
159 echo "with the '-d' option"
164 ## Usage: initFilesystem [force]
165 function initFilesystem
167 test -z "$1" || _renameVserverCfg
168 test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || {
169 echo "vserver-topdirectory and/or configuration exist already; "
170 echo "please try to use '--force', or remove them manually"
174 mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt "$VDIR"/{dev/pts,etc} "$SETUP_LOCKREVDIR"
176 ln -s "$VDIR" "$SETUP_CONFDIR/vdir"
178 test -z "$PKGCFGDIR" || {
179 ln -s "$PKGCFGDIR" "$SETUP_CONFDIR/apps/pkgmgmt/base"
181 test "$_EXECDIR" = / || ln -s "$_EXECDIR" "$confdir/apps/pkgmgmt/execdir"
186 makeDevEntry "$VDIR"/dev $spec
189 findAndCopy "$VDIR"/etc/hosts "$CONFDIR"/.defaults/files/hosts "$CONFDIR/.distributions/$DISTRIBUTION"/files/hosts \
190 "$DISTRIBDIR/$DISTRIBUTION"/files/hosts "$DISTRIBDIR"/defaults/files/hosts ""
192 for i in nsswitch.conf krb5.conf krb.conf krb.realms ldap.conf localtime resolv.conf; do
193 findAndCopy "$VDIR"/etc/$i "$CONFDIR/.defaults/files/$i" "$CONFDIR/.distributions/$DISTRIBUTION/files/$i" ""
197 function initVariables
204 findFile _DEV_FILE "$CONFDIR/.distributions/$DISTRIBUTION/devs" "$DISTRIBDIR/$DISTRIBUTION/devs" "$DISTRIBDIR/defaults/devs"
205 findDir _EXECDIR "$CONFDIR/.distributions/$DISTRIBUTION/execdir" "$DISTRIBDIR/$DISTRIBUTION/execdir" /
206 findFile BUILD_INITPRE "$CONFDIR/.distributions/$DISTRIBUTION/initpre" "$DISTRIBDIR/$DISTRIBUTION/initpre" ""
207 findFile BUILD_INITPOST "$CONFDIR/.distributions/$DISTRIBUTION/initpost" "$DISTRIBDIR/$DISTRIBUTION/initpost" ""
208 findDir PKGDIR "$CONFDIR/.distributions/$DISTRIBUTION/pkgs" "$DISTRIBDIR/$DISTRIBUTION/pkgs" /