initial checkin
[util-vserver.git] / util-vserver / 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 USR_LIB_VSERVER=$(dirname $0)
22 vserver_mknod()
23 {
24         mknod $1 $2 $3 $4
25         chmod $5 $1
26 }
27
28 if [ $# != 1 ] ; then
29         echo install-post.sh vserver
30 else
31         VROOT=/vservers/$1
32         rm -fr $VROOT/dev
33         mkdir $VROOT/dev && chmod 755 $VROOT/dev
34         mkdir $VROOT/dev/pts
35         vserver_mknod $VROOT/dev/null c 1 3 666
36         vserver_mknod $VROOT/dev/zero c 1 5 666
37         vserver_mknod $VROOT/dev/full c 1 7 666
38         vserver_mknod $VROOT/dev/random c 1 8 644
39         vserver_mknod $VROOT/dev/urandom c 1 9 644
40         vserver_mknod $VROOT/dev/tty c 5 0 666
41         vserver_mknod $VROOT/dev/ptmx c 5 2 666
42         test -f /etc/vservers/$1.conf || cp $USR_LIB_VSERVER/sample.conf /etc/vservers/$1.conf
43         test -f /etc/vservers/$1.sh   || cp $USR_LIB_VSERVER/sample.sh /etc/vservers/$1.sh
44         echo NETWORKING=yes >$VROOT/etc/sysconfig/network
45         echo HOSTNAME=$1 >>$VROOT/etc/sysconfig/network
46         (
47                 cd $VROOT/etc/rc.d/init.d || cd $VROOT/etc/init.d
48                 for serv in *
49                 do
50                         case $serv in
51                         *.bak|*~|functions|killall|halt|single)
52                                 ;;
53                         *)
54                                 $USR_LIB_VSERVER/capchroot /vservers/$1 /sbin/chkconfig --level 2345 $serv off
55                                 ;;
56                         esac
57                 done
58                 rm -f $VROOT/etc/rc.d/rc6.d/S*reboot
59         )
60         if [ ! -f $VROOT/etc/fstab ] ; then
61                 echo /dev/hdv1  /       ext2    defaults        1       1 >$VROOT/etc/fstab
62                 echo /dev/hdv1  /       ext2    rw      1       1 >$VROOT/etc/mtab
63         fi
64         cp -a $USR_LIB_VSERVER/vreboot $VROOT/sbin/.
65         ln -sf vreboot $VROOT/sbin/vhalt
66         if [ -x /etc/vservers/install-post.sh ]; then
67                 /etc/vservers/install-post.sh $VROOT
68         fi
69 fi
70