2 echo "Starting Kickstart Post"
3 PATH=/sbin:/usr/sbin:/bin:/usr/bin
6 echo "Running ovirt-install-host stateless"
7 /usr/sbin/ovirt-install-node stateless
9 echo "Creating shadow files"
10 # because we aren't installing authconfig, we aren't setting up shadow
11 # and gshadow properly. Do it by hand here
15 echo "Forcing C locale"
16 # force logins (via ssh, etc) to use C locale, since we remove locales
17 cat >> /etc/profile << \EOF
18 # oVirt: force our locale to C since we don't have locale stuff'
19 export LC_ALL=C LANG=C
22 echo "Configuring IPTables"
23 # here, we need to punch the appropriate holes in the firewall
24 cat > /etc/sysconfig/iptables << \EOF
25 # oVirt automatically generated firewall configuration
30 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
31 -A INPUT -p icmp -j ACCEPT
32 -A INPUT -i lo -j ACCEPT
34 -A INPUT -p tcp --dport 16509 -j ACCEPT
36 -A INPUT -p tcp --dport 22 -j ACCEPT
38 -A INPUT -p tcp -m multiport --dports 5900:6000 -j ACCEPT
40 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
41 -A INPUT -j REJECT --reject-with icmp-host-prohibited
42 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp-host-prohibited
46 # make disks available to VMs
47 cat > /tmp/ovirt.te <<EOF
50 type fixed_disk_device_t;
52 class blk_file { ioctl getattr setattr read write };
54 allow qemu_t fixed_disk_device_t:blk_file { ioctl getattr setattr read write };
56 checkmodule -M -m -o /tmp/ovirt.mod /tmp/ovirt.te
57 semodule_package -o /tmp/ovirt.pp -m /tmp/ovirt.mod
58 semodule -i /tmp/ovirt.pp
60 echo "Removing excess RPMs"
62 RPM="rpm -v -e --nodeps"
64 # kernel pulls in mkinitrd which pulls in isomd5sum which pulls in python,
65 # and livecd-tools needs lokkit to configure SELinux.
66 # However, this is just an install-time dependency; we can remove
67 # it afterwards, which we do here
68 $RPM -e system-config-firewall-tui system-config-network-tui rhpl \
69 rpm-python dbus-python kudzu newt-python newt
71 $RPM -e kpartx mkinitrd isomd5sum dmraid python python-libs
74 # Remove additional RPMs forcefully
75 $RPM gamin pm-utils kbd libuser passwd usermode \
76 vbetool ConsoleKit hdparm \
77 efibootmgr krb5-workstation linux-atm-libs fedora-release-notes \
78 slang psmisc gdbm cryptsetup-luks pciutils mtools syslinux db4 \
79 wireless-tools radeontool cracklib-dicts cracklib
81 # Things we could probably remove if libvirt didn't link against them
82 #$RPM avahi PolicyKit xen-libs
84 # Things we could probably remove if qemu-kvm didn't link against them
87 # Pam complains when this is missing
92 echo "Removing excess kernel modules"
93 MODULES="/lib/modules/*/kernel"
95 # the following are lists of kernel modules we are pretty sure we won't need;
96 # note that these can be single files or whole directories. They are specified
97 # starting at $MODULES above; so if you want to remove the NLS stuff from the
98 # fs subdir, your mods entry would be "fs/nls"
99 fs_mods="fs/nls fs/9p fs/affs fs/autofs fs/autofs4 fs/befs fs/bfs fs/cifs \
100 fs/coda fs/cramfs fs/dlm fs/ecryptfs fs/efs fs/exportfs fs/ext4 \
101 fs/freevxfs fs/fuse fs/gfs2 fs/hfs fs/hfsplus fs/jbd fs/jbd2 fs/jffs \
102 fs/jffs2 fs/jfs fs/minix fs/ncpfs fs/ocfs2 fs/qnx4 fs/reiserfs \
103 fs/romfs fs/sysv fs/udf fs/ufs fs/xfs"
105 net_mods="net/802 net/8021q net/9p net/appletalk net/atm net/ax25 \
106 net/bluetooth net/dccp net/decnet net/ieee80211 net/ipx net/irda \
107 net/mac80211 net/netrom net/rfkill net/rose net/sched net/tipc \
108 net/wanrouter net/wireless"
110 driver_mods="drivers/auxdisplay drivers/net/appletalk \
111 drivers/net/hamradio drivers/net/pcmcia drivers/net/tokenring \
112 drivers/net/wireless drivers/net/irda drivers/atm drivers/usb/atm \
113 drivers/acpi drivers/char/drm drivers/char/mwave \
114 drivers/char/ipmp drivers/char/pcmcia drivers/crypto drivers/dca \
115 drivers/firmware drivers/memstick drivers/mmc drivers/mfs \
116 drivers/parport drivers/video drivers/watchdog drivers/net/ppp* \
117 drivers/usb/serial drivers/usb/misc drivers/usb/class \
118 drivers/usb/image drivers/rtc"
120 misc_mods="drivers/bluetooth drivers/firewire drivers/i2c drivers/isdn \
121 drivers/media drivers/misc drivers/leds drivers/mtd drivers/w1 sound \
122 drivers/input drivers/pcmcia drivers/scsi/pcmcia"
124 for mods in $fs_mods $net_mods $misc_mods $driver_mods ; do
128 echo "Removing all timezones except for UTC"
129 find /usr/share/zoneinfo -regextype egrep -type f \
130 ! -regex ".*/UTC|.*/GMT" -exec $RM {} \;
132 echo "Removing blacklisted files and directories"
133 blacklist="/boot /etc/alsa /etc/pki /usr/share/hwdata/MonitorsDB \
134 /usr/share/hwdata/oui.txt /usr/share/hwdata/videoaliases \
135 /usr/share/hwdata/videodrivers /usr/share/fedora-release \
136 /usr/share/tabset /usr/share/libvirt /usr/share/augeas/lenses/tests \
137 /usr/share/tc /usr/share/emacs /usr/share/info /usr/kerberos \
138 /usr/src /usr/etc /usr/games /usr/include /usr/local \
139 /usr/sbin/{dell*,sasldblistusers2,build-locale-archive,glibc_post_upgrade.*}"
140 blacklist_lib="/usr/lib{,64}/python2.5 /usr/lib{,64}/gconv \
141 /usr/{,lib64}/tc /usr/lib{,64}/tls /usr/lib{,64}/sse2 \
142 /usr/lib{,64}/pkgconfig /usr/lib{,64}/nss /usr/lib{,64}/X11 \
143 /usr/lib{,64}/games /usr/lib{,64}/alsa-lib /usr/lib{,64}/fs/reiserfs \
144 /usr/lib{,64}/krb5 /usr/lib{,64}/hal /usr/lib{,64}/gio \
145 /lib/terminfo/d /lib/terminfo/v /lib/terminfo/a \
146 /lib/firmware /usr/lib/locale /usr/lib/syslinux"
147 blacklist_pango="/usr/lib{,64}/pango /usr/lib{,64}/libpango* \
148 /etc/pango /usr/bin/pango*"
149 blacklist_hal="/usr/bin/hal-device /usr/bin/hal-disable-polling \
150 /usr/bin/hal-find-by-capability /usr/bin/hal-find-by-property \
151 /usr/bin/hal-is-caller-locked-out /usr/bin/hal-is-caller-privileged \
152 /usr/bin/hal-lock /usr/bin/hal-set-property /usr/bin/hal-setup-keymap"
153 blacklist_ssh="/usr/bin/sftp /usr/bin/slogin /usr/bin/ssh /usr/bin/ssh-add \
154 /usr/bin/ssh-agent /usr/bin/ssh-copy-id /usr/bin/ssh-keyscan"
155 docs_blacklist="/usr/share/omf /usr/share/gnome /usr/share/doc \
156 /usr/share/locale /usr/share/libthai /usr/share/man /usr/share/terminfo \
157 /usr/share/X11 /usr/share/i18n"
159 eval $RM $blacklist $blacklist_lib $blacklist_pango $blacklist_hal \
160 $blacklist_ssh $docs_blacklist
162 echo "Cleanup empty directory structures in /usr/share"
163 find /usr/share -type d -exec rmdir {} \; > /dev/null 2>&1
165 echo "Finished Kickstart Post"