use $(LIBENSCVECTOR) instead of libensc_vector.a
[util-vserver.git] / util-vserver / distrib / redhat / initpost
1 #! /bin/bash
2
3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 #  
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.
8 #  
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.
13 #  
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.
17
18 ## HACK: this script is full of races...
19
20 vdir=$1/vdir
21 . "$2"
22
23 function relink
24 {
25     test ! -e "$2" -o -L "$2" || mv -f "$2"{,.orig}
26     ln -s "$1" "$2"
27 }
28
29 ## Usage: subst <file> <regexp>
30 function subst
31 {
32     sed -e "$2" "$1" | $_CHROOT_CAT "$1".tmp
33     cmp -s "$1".tmp "$1" || cat "$1".tmp | $_CHROOT_CAT "$1"
34     rm -f "$1".tmp
35 }
36
37 pushd "$vdir"/etc/init.d &>/dev/null ||
38     pushd "$vdir"/etc/rc.d/init.d &>/dev/null || exit 1
39
40     for i in *; do
41         test -e "$i" || continue
42         case "$i" in
43             functions|halt|killall|single) ;;
44             syslog) ;;
45             *)
46                 $_VSERVER ----insecure "$1" chkconfig "$i" off
47                 ;;
48         esac
49     done
50
51     relink /bin/true halt
52 popd >/dev/null
53
54 pushd "$vdir"/sbin &>/dev/null
55     relink /bin/true new-kernel-pkg
56 popd >/dev/null
57
58 pushd "$vdir"/usr/bin &>/dev/null
59     relink /bin/true rhgb-client
60 popd >/dev/null
61
62 pushd "$vdir"/etc &>/dev/null
63     # TODO: remove race/symlink-attack
64     echo 'NETWORKING=yes' >>sysconfig/network
65 popd >/dev/null
66
67 pushd "$vdir" &>/dev/null
68     : | $_CHROOT_CAT /etc/sysctl.conf
69     echo "none    /       none    defaults" | $_CHROOT_CAT /etc/fstab
70     cat "$__DISTRIBDIR"/redhat/rc.sysinit   | $_CHROOT_CAT /etc/rc.d/rc.sysinit.vserver
71     # TODO: remove race/symlink-attack
72     chmod +x etc/rc.d/rc.sysinit.vserver
73     subst etc/inittab 's!^\([^#].*:respawn:.* tty\)!#\1!;
74                        s!si::sysinit:/etc/rc.d/rc.sysinit!si::sysinit:/etc/rc.d/rc.sysinit.vserver!'
75 popd >/dev/null