- moved here from sysv/
[util-vserver.git] / distrib / install-post.sh
1 #!/bin/sh
2
3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 # based on distrib/install-post 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 # Complete the installation of a vserver
21 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
22 test -e "$UTIL_VSERVER_VARS" || {
23     echo "Can not find util-vserver installation; aborting..."
24     exit 1
25 }
26 . "$UTIL_VSERVER_VARS"
27
28 USR_LIB_VSERVER=$PKGLIBDIR
29
30 vserver_mknod()
31 {
32         mknod $1 $2 $3 $4
33         chmod $5 $1
34 }
35
36 if [ $# != 1 ] ; then
37         echo install-post.sh vserver
38 else
39         VROOT=$VROOTDIR/$1
40         rm -fr $VROOT/dev
41         mkdir $VROOT/dev && chmod 755 $VROOT/dev
42         mkdir $VROOT/dev/pts
43         vserver_mknod $VROOT/dev/null c 1 3 666
44         vserver_mknod $VROOT/dev/zero c 1 5 666
45         vserver_mknod $VROOT/dev/full c 1 7 666
46         vserver_mknod $VROOT/dev/random c 1 8 644
47         vserver_mknod $VROOT/dev/urandom c 1 9 644
48         vserver_mknod $VROOT/dev/tty c 5 0 666
49         vserver_mknod $VROOT/dev/ptmx c 5 2 666
50         test -f /etc/vservers/$1.conf || cp $USR_LIB_VSERVER/sample.conf /etc/vservers/$1.conf
51         test -f /etc/vservers/$1.sh   || cp $USR_LIB_VSERVER/sample.sh /etc/vservers/$1.sh
52         echo NETWORKING=yes >$VROOT/etc/sysconfig/network
53         echo HOSTNAME=$1 >>$VROOT/etc/sysconfig/network
54         (
55                 cd $VROOT/etc/rc.d/init.d || cd $VROOT/etc/init.d
56                 for serv in *
57                 do
58                         case $serv in
59                         *.bak|*~|functions|killall|halt|single)
60                                 ;;
61                         *)
62                                 $USR_LIB_VSERVER/capchroot $VROOTDIR/$1 /sbin/chkconfig --level 2345 $serv off
63                                 ;;
64                         esac
65                 done
66                 rm -f $VROOT/etc/rc.d/rc6.d/S*reboot
67         )
68         if [ ! -f $VROOT/etc/fstab ] ; then
69                 echo /dev/hdv1  /       ext2    defaults        1       1 >$VROOT/etc/fstab
70                 echo /dev/hdv1  /       ext2    rw      1       1 >$VROOT/etc/mtab
71         fi
72         cp -a $USR_LIB_VSERVER/vreboot $VROOT/sbin/.
73         ln -sf vreboot $VROOT/sbin/vhalt
74         if [ -x /etc/vservers/install-post.sh ]; then
75                 /etc/vservers/install-post.sh $VROOT
76         fi
77 fi
78