- moved here from sysv/
[util-vserver.git] / distrib / install-pre.sh
1 #!/bin/sh
2
3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 # based on distrib/install-pre by Jacques Gelinas
5 #  
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #  
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #  
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
21 test -e "$UTIL_VSERVER_VARS" || {
22     echo "Can not find util-vserver installation; aborting..."
23     exit 1
24 }
25 . "$UTIL_VSERVER_VARS"
26
27 vserver_mknod()
28 {
29         mknod $1 $2 $3 $4
30         chmod $5 $1
31 }
32
33 if [ $# != 1 ] ; then
34         echo install-pre.sh vserver
35 else
36         mkdir -p /etc/vservers
37         mkdir -p $VROOTDIR 2>/dev/null
38         VROOT=$VROOTDIR/$1
39         mkdir -p -m755 $VROOT
40         chattr -t $VROOT
41         rm -fr $VROOT/dev
42         mkdir -p $VROOT/dev && chmod 755 $VROOT/dev
43         mkdir $VROOT/dev/pts
44         vserver_mknod $VROOT/dev/null c 1 3 666
45         vserver_mknod $VROOT/dev/zero c 1 5 666
46         vserver_mknod $VROOT/dev/full c 1 7 666
47         vserver_mknod $VROOT/dev/random c 1 8 644
48         vserver_mknod $VROOT/dev/urandom c 1 9 644
49         vserver_mknod $VROOT/dev/tty c 5 0 666
50         vserver_mknod $VROOT/dev/ptmx c 5 2 666
51         # We fake this device to help some package managers
52         touch $VROOT/dev/hdv1
53 fi
54