alias vi to vi + restorecon
[ovirt-node-image.git] / common-post.ks
blobdcd44d62b857d81dcb8a9685f74e1d3aca13d635
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 else
119     echo "Building in production mode, locking root account"
120     passwd -l root
123 # directories required in the image with the correct perms
124 # config persistance currently handles only regular files
125 mkdir -p /root/.ssh
126 chmod 700 /root/.ssh
128 # fix iSCSI/LVM startup issue
129 sed -i 's/node\.session\.initial_login_retry_max.*/node.session.initial_login_retry_max = 60/' /etc/iscsi/iscsid.conf
131 # root's bash profile
132 cat >> /root/.bashrc <<EOF
133 # aliases used for the temporary
134 function mod_vi() {
135   /bin/vi \$@
136   restorecon -v \$@
138 alias vi="mod_vi"
139 alias ping='ping -c 3'
142 # Remove the default logrotate daily cron job
143 # since we run it every 10 minutes instead.
144 rm -f /etc/cron.daily/logrotate