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
37 (c|b) mknod -m$6 "$dst" $3 $4 $5;;
38 (d) mkdir -p -m$4 "$dst";;
42 (*) echo "Unknown dev-entry mode '$3'" >&2
48 function populateDirectory
57 for file in "$i"/*; do
58 test -e "$file" || continue
60 (*/CVS) test ! -d "$file" || continue;;
61 (*.rpmsave|*.rpmnew|*.rpmorig)
72 test -z "$ROOTDIR" || return 0
74 for item in "\"$CONFDIR/.defaults/vdirbase\" 1" "$DEFAULT_VSERVERDIR"; do
78 test ! -d "$ROOTDIR" || break
81 test -d "$ROOTDIR" || {
82 echo "Root-directory '$ROOTDIR' does not exist or is invalid" >&2
87 function _setVserverDir
89 test -z "$VSERVERDIRNAME" || return 0
90 VSERVERDIRNAME="$VSERVER_NAME"
95 VDIR="$ROOTDIR/$VSERVERDIRNAME"
100 test -z "$OPTION_SILENT" || return 0
104 function _renameVserverCfg
106 local suffix=.~$(date +'%s')~
109 for i in "$VDIR" "$SETUP_CONFDIR"; do
112 say "Renamed '$i' to '$i$suffix'"
117 function getDistribution
119 test -z "$DISTRIBUTION" || return 0
121 if test -e /etc/fedora-release; then
122 set -- $(cat /etc/fedora-release)
124 elif test -e /etc/redhat-release; then
125 set -- $(cat /etc/redhat-release)
127 elif test -e /etc/debian_version; then
128 set -- $(cat /etc/debian_version)
132 "Can not determine distribution; please specify it manually
133 with the '-d' option" >&2
138 ## Usage: initFilesystem [force]
139 function base.initFilesystem
141 test -z "$1" || _renameVserverCfg
142 test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || {
144 "vserver-topdirectory and/or configuration exist already;
145 please try to use '--force', or remove them manually" >&2
149 mkdir -p -m755 "$VDIR"
151 mkdir -p -m755 "$SETUP_CONFDIR"/apps "$VDIR"/{dev/pts,etc} "$SETUP_LOCKREVDIR"
153 ln -s "$VDIR" "$SETUP_CONFDIR/vdir"
157 makeDevEntry "$VDIR"/dev $spec
160 mkdir -p "$VDIR"/proc
161 findAndCopy "$VDIR"/etc/hosts "$CONFDIR"/.defaults/files/hosts "$CONFDIR/.distributions/$DISTRIBUTION"/files/hosts \
162 "$DISTRIBDIR/$DISTRIBUTION"/files/hosts "$DISTRIBDIR"/defaults/files/hosts ""
164 for i in nsswitch.conf krb5.conf krb.conf krb.realms ldap.conf localtime resolv.conf; do
165 findAndCopy "$VDIR"/etc/$i "$CONFDIR/.defaults/files/$i" "$CONFDIR/.distributions/$DISTRIBUTION/files/$i" ""
169 function base.initVariables
175 findFile _DEV_FILE "$CONFDIR/.distributions/$DISTRIBUTION/devs" "$DISTRIBDIR/$DISTRIBUTION/devs" "$DISTRIBDIR/defaults/devs"
176 findDir _EXECDIR "$CONFDIR/.distributions/$DISTRIBUTION/execdir" "$DISTRIBDIR/$DISTRIBUTION/execdir" /
177 findFile BUILD_INITPRE "$CONFDIR/.distributions/$DISTRIBUTION/initpre" "$DISTRIBDIR/$DISTRIBUTION/initpre" ""
178 findFile BUILD_INITPOST "$CONFDIR/.distributions/$DISTRIBUTION/initpost" "$DISTRIBDIR/$DISTRIBUTION/initpost" ""