Revert "workaround for gpxe issue with the virt-preview"
[ovirt-node-image.git] / common-post.ks
blob3a23c024b53f045fdddfbf8b9c6e0465d4e88fe7
1 # -*-Shell-script-*-
2 echo "Starting Kickstart Post"
3 PATH=/sbin:/usr/sbin:/bin:/usr/bin
4 export PATH
6 # Import SELinux Modules
7 echo "Enabling selinux modules"
8 SEMODULES="base automount avahi consolekit cyrus dhcp dnsmasq guest hal ipsec \
9 iscsi kerberos kerneloops ldap lockdev logadm mozilla ntp ovirt-node-selinux \
10 polkit portmap qemu rpcbind sasl snmp stunnel sysstat tcpd unprivuser \
11 unconfined usbmodules userhelper virt"
13 lokkit -v --selinuxtype=minimum
14 tmpdir=$(mktemp -d)
16 for semodule in $SEMODULES; do
17     found=0
18     pp_file=/usr/share/selinux/minimum/$semodule.pp
19     if [ -f $pp_file.bz2 ]; then
20         bzip2 -dc $pp_file.bz2 > "$tmpdir/$semodule.pp"
21         rm $pp_file.bz2
22         found=1
23     elif [ -f $pp_file ]; then
24         mv $pp_file "$tmpdir"
25         found=1
26     fi
27     # Don't put "base.pp" on the list.
28     test $semodule = base \
29         && continue
30     test $found=1 \
31         && modules="$modules $semodule.pp"
32 done
34 if test -n "$modules"; then
35     (cd "$tmpdir" \
36         && test -f base.pp \
37         && semodule -v -b base.pp -i $modules \
38         && semodule -v -B )
40 rm -rf "$tmpdir"
42 echo "Running ovirt-install-node-stateless"
43 ovirt-install-node-stateless
45 echo "Creating shadow files"
46 # because we aren't installing authconfig, we aren't setting up shadow
47 # and gshadow properly.  Do it by hand here
48 pwconv
49 grpconv
51 echo "Forcing C locale"
52 # force logins (via ssh, etc) to use C locale, since we remove locales
53 cat >> /etc/profile << \EOF
54 # oVirt: force our locale to C since we don't have locale stuff'
55 export LC_ALL=C LANG=C
56 EOF
58 echo "Configuring IPTables"
59 # here, we need to punch the appropriate holes in the firewall
60 cat > /etc/sysconfig/iptables << \EOF
61 # oVirt automatically generated firewall configuration
62 *filter
63 :INPUT ACCEPT [0:0]
64 :FORWARD ACCEPT [0:0]
65 :OUTPUT ACCEPT [0:0]
66 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
67 -A INPUT -p icmp -j ACCEPT
68 -A INPUT -i lo -j ACCEPT
69 # libvirt
70 -A INPUT -p tcp --dport 16509 -j ACCEPT
71 # SSH
72 -A INPUT -p tcp --dport 22 -j ACCEPT
73 # anyterm
74 -A INPUT -p tcp --dport 81 -j ACCEPT
75 # guest consoles
76 -A INPUT -p tcp -m multiport --dports 5800:6000 -j ACCEPT
77 # migration
78 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
79 -A INPUT -j REJECT --reject-with icmp-host-prohibited
80 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp-host-prohibited
81 COMMIT
82 EOF
83 # configure IPv6 firewall, default is all ACCEPT
84 cat > /etc/sysconfig/ip6tables << \EOF
85 # oVirt automatically generated firewall configuration
86 *filter
87 :INPUT ACCEPT [0:0]
88 :FORWARD ACCEPT [0:0]
89 :OUTPUT ACCEPT [0:0]
90 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
91 -A INPUT -p ipv6-icmp -j ACCEPT
92 -A INPUT -i lo -j ACCEPT
93 # libvirt
94 -A INPUT -p tcp --dport 16509 -j ACCEPT
95 # SSH
96 -A INPUT -p tcp --dport 22 -j ACCEPT
97 # anyterm
98 -A INPUT -p tcp --dport 81 -j ACCEPT
99 # guest consoles
100 -A INPUT -p tcp -m multiport --dports 5800:6000 -j ACCEPT
101 # migration
102 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
103 -A INPUT -j REJECT --reject-with icmp6-adm-prohibited
104 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp6-adm-prohibited
105 COMMIT
108 # remove errors from /sbin/dhclient-script
109 DHSCRIPT=/sbin/dhclient-script
110 sed -i 's/mv /cp -p /g'  $DHSCRIPT
111 sed -i '/rm -f.*${interface}/d' $DHSCRIPT
112 sed -i '/rm -f \/etc\/localtime/d' $DHSCRIPT
113 sed -i '/rm -f \/etc\/ntp.conf/d' $DHSCRIPT
114 sed -i '/rm -f \/etc\/yp.conf/d' $DHSCRIPT
116 if rpm -q --qf '%{release}' ovirt-node | grep -q "^0\." ; then
117     echo "Building in developer mode, leaving root account unlocked"
118     augtool <<\EOF
119 set /files/etc/ssh/sshd_config/PermitEmptyPasswords yes
120 save
122 else
123     echo "Building in production mode, locking root account"
124     passwd -l root
127 # directories required in the image with the correct perms
128 # config persistance currently handles only regular files
129 mkdir -p /root/.ssh
130 chmod 700 /root/.ssh
132 # fix iSCSI/LVM startup issue
133 sed -i 's/node\.session\.initial_login_retry_max.*/node.session.initial_login_retry_max = 60/' /etc/iscsi/iscsid.conf
135 # root's bash profile
136 cat >> /root/.bashrc <<EOF
137 # aliases used for the temporary
138 function mod_vi() {
139   /bin/vi \$@
140   restorecon -v \$@
142 alias vi="mod_vi"
143 alias ping='ping -c 3'
146 # Remove the default logrotate daily cron job
147 # since we run it every 10 minutes instead.
148 rm -f /etc/cron.daily/logrotate
150 # comment out /etc/* entries in rwtab to prevent overlapping mounts
151 touch /var/lib/random-seed
152 mkdir /live
153 mkdir /boot
154 sed -i '/^files \/etc*/ s/^/#/' /etc/rwtab
155 cat > /etc/rwtab.d/ovirt <<EOF
156 files   /etc
157 dirs    /var/lib/dnsmasq
158 files   /var/cache/libvirt
159 files   /var/cache/hald
160 files   /var/empty/sshd/etc/localtime
161 files   /var/lib/dbus
162 files   /var/lib/libvirt
163 empty   /mnt
164 empty   /live
165 empty   /boot