1 # add RHEV-H rwtab locations
3 mkdir -p /var/cache/rhn
4 cat > /etc/rwtab.d/rhev << EOF_RWTAB_RHEVH
12 # convenience symlinks
13 ln -s /usr/libexec/ovirt-config-rhn /sbin/rhn_register
14 ln -s /usr/libexec/ovirt-config-setup /usr/sbin/setup
16 # in RHEV-H *.py are blacklisted
17 cat > /etc/cron.d/rhn-virtualization.cron << \EOF_cron-rhn
18 0-59/2 * * * * root python /usr/share/rhn/virtualization/poller.pyc
21 # minimal lsb_release for vdsm-reg (bz#549147)
22 cat > /usr/bin/lsb_release <<\EOF_LSB
24 if [ "$1" = "-r" ]; then
25 printf "Release:\t$(cat /etc/rhev-hypervisor-release | awk '{print $7}')\n"
27 echo RedHatEnterpriseVirtualizationHypervisor
30 chmod +x /usr/bin/lsb_release
32 # CPE name rhbz#593463
33 cat > /etc/system-release-cpe <<\EOF_CPE
34 cpe:/o:redhat:enterprise_linux:6:update2:hypervisor
37 patch -d /usr/share/rhn/up2date_client -p0 << \EOF_up2date_patch2
38 --- up2dateErrors.py.orig 2011-07-02 11:06:46.000000000 +0000
39 +++ up2dateErrors.py 2011-07-02 11:09:19.000000000 +0000
44 -from yum.Errors import RepoError
46 +class RepoError(Exception):
48 + Base Yum Error. All other Errors thrown by yum should inherit from
51 + def __init__(self, value=None):
52 + Exception.__init__(self)
55 + return "%s" %(self.value,)
57 + def __unicode__(self):
58 + return '%s' % to_unicode(self.value)
61 """base class for errors"""
63 python -m compileall /usr/share/rhn/up2date_client
65 patch -d /usr/share/rhn/virtualization -p0 << \EOF_rhn_virt
66 --- poller.py.orig 2011-04-19 15:53:43.000000000 +0000
67 +++ poller.py 2011-09-08 20:45:49.000000000 +0000
72 - conn = libvirt.open(None)
73 + conn = libvirt.openReadOnly(None)
74 except libvirt.libvirtError, lve:
75 # virConnectOpen() failed
76 - sys.stderr.write("Warning: Could not retrieve virtualization information!\n\tlibvirtd service needs to be running.\n")
83 # Crawl each of the domains on this host and obtain the new state.
85 - domain_list = poll_through_vdsm()
88 domain_list = poll_hypervisor()
90 + domain_list = poll_through_vdsm()
92 # If no libvirt nor vdsm is present, this program is pretty much
95 python -m compileall /usr/share/rhn/virtualization
97 echo "Configuring SELinux"
98 # custom module for node specific rules
101 cat > ovirt.te << \EOF_OVIRT_TE
110 class file { append mounton open getattr read execute ioctl lock entrypoint };
112 class process { sigchld signull transition noatsecure siginh rlimitinh getattr };
113 class fifo_file { getattr open read write append lock ioctl };
114 class filesystem getattr;
115 class dir { getattr search open read lock ioctl };
116 class socket { read write };
117 class tcp_socket { read write };
118 class udp_socket { read write };
119 class rawip_socket { read write };
120 class netlink_socket { read write };
121 class packet_socket { read write };
122 class unix_stream_socket { read write create ioctl getattr lock setattr append bind connect getopt setopt shutdown connectto };
123 class unix_dgram_socket { read write };
124 class appletalk_socket { read write };
125 class netlink_route_socket { read write };
126 class netlink_firewall_socket { read write };
127 class netlink_tcpdiag_socket { read write };
128 class netlink_nflog_socket { read write };
129 class netlink_xfrm_socket { read write };
130 class netlink_selinux_socket { read write };
131 class netlink_audit_socket { read write };
132 class netlink_ip6fw_socket { read write };
133 class netlink_dnrt_socket { read write };
134 class netlink_kobject_uevent_socket { read write };
135 class tun_socket { read write };
136 class chr_file { getattr read write append ioctl lock open };
137 class lnk_file { getattr read };
138 class sock_file { getattr write open append };
140 allow mount_t shadow_t:file mounton;
141 allow setfiles_t initrc_tmp_t:file append;
143 init_daemon_domain(unconfined_t,ovirt_exec_t)
145 cat > ovirt.fc << \EOF_OVIRT_FC
146 /etc/rc\.d/init\.d/ovirt-firstboot -- gen_context(system_u:object_r:ovirt_exec_t)
147 /etc/rc\.d/init\.d/ovirt-post -- gen_context(system_u:object_r:ovirt_exec_t)
149 make NAME=targeted -f /usr/share/selinux/devel/Makefile
150 semodule -v -i ovirt.pp
154 echo "Configuring IPTables"
155 # here, we need to punch the appropriate holes in the firewall
156 cat > /etc/sysconfig/iptables << \EOF
157 # oVirt automatically generated firewall configuration
160 :FORWARD ACCEPT [0:0]
162 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
163 -A INPUT -p icmp -j ACCEPT
164 -A INPUT -i lo -j ACCEPT
166 -A INPUT -p tcp --dport 54321 -j ACCEPT
168 -A INPUT -p tcp --dport 16514 -j ACCEPT
170 -A INPUT -p tcp --dport 22 -j ACCEPT
172 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
174 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
176 -A INPUT -p udp --dport 161 -j ACCEPT
178 -A INPUT -j REJECT --reject-with icmp-host-prohibited
179 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp-host-prohibited
182 # configure IPv6 firewall, default is all ACCEPT
183 cat > /etc/sysconfig/ip6tables << \EOF
184 # oVirt automatically generated firewall configuration
187 :FORWARD ACCEPT [0:0]
189 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
190 -A INPUT -p ipv6-icmp -j ACCEPT
191 -A INPUT -i lo -j ACCEPT
193 -A INPUT -p tcp --dport 16514 -j ACCEPT
195 -A INPUT -p tcp --dport 22 -j ACCEPT
197 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
199 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
201 -A INPUT -p udp --dport 161 -j ACCEPT
202 # unblock ipv6 dhcp response
203 -A INPUT -p udp --dport 546 -j ACCEPT
204 -A INPUT -j REJECT --reject-with icmp6-adm-prohibited
205 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp6-adm-prohibited
209 # remove errors from /sbin/dhclient-script
210 DHSCRIPT=/sbin/dhclient-script
211 sed -i 's/mv /cp -p /g' $DHSCRIPT
212 sed -i '/rm -f.*${interface}/d' $DHSCRIPT
213 sed -i '/rm -f \/etc\/localtime/d' $DHSCRIPT
214 sed -i '/rm -f \/etc\/ntp.conf/d' $DHSCRIPT
215 sed -i '/rm -f \/etc\/yp.conf/d' $DHSCRIPT
217 # prevent node from hanging on reboot due to /etc mounts
218 patch -d /etc/init.d/ -p0 << \EOF_halt
219 --- halt.orig 2009-12-05 00:44:29.000000000 +0000
220 +++ halt 2010-03-24 18:12:36.000000000 +0000
222 $"Unmounting pipe file systems (retry): " \
225 -LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
226 +LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/etc|^\/dev/{next}
227 $3 == "tmpfs" || $3 == "proc" {print $2 ; next}
228 /(loopfs|autofs|nfs|cifs|smbfs|ncpfs|sysfs|^none|^\/dev\/ram|^\/dev\/root$)/ {next}
229 {print $2}' /proc/mounts \
234 patch -d /etc/rc.d -p0 << \EOF_rc_sysinit
235 --- rc.sysinit.orig 2011-04-06 09:11:18.126385229 -0400
236 +++ rc.sysinit 2011-04-06 09:11:04.195923990 -0400
240 if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then
241 - /sbin/restorecon -R /dev 2>/dev/null
242 + /sbin/restorecon -e /dev/.initramfs -R /dev 2>/dev/null
247 # mounted). Contrary to standard usage,
248 # filesystems are NOT unmounted in single user mode.
249 if [ "$READONLY" != "yes" ] ; then
250 - action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
251 + action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2,noproc,nosysfs,nodevpts -O no_netdev
253 - action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
254 + action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2,noproc,nosysfs,nodevpts -O no_netdev
257 # Update quotas if necessary
262 patch -d /sbin -p0 << \EOF_start_udev
263 --- start_udev.orig 2011-03-30 12:32:03.000000000 +0000
264 +++ start_udev 2011-09-02 17:16:57.954610422 +0000
266 #/bin/chown root:root /dev/fuse
268 if [ -x /sbin/restorecon ]; then
269 - /sbin/restorecon -R /dev
270 + /sbin/restorecon -e /dev/.initramfs -R /dev
273 if [ -x "$MAKEDEV" ]; then
276 # semanage is not present in the image and virt_use_nfs is on (see rhbz#642209)
277 # remove it from vdsmd startup script to avoid error
278 sed -i 's#/usr/sbin/semanage#/bin/true#' /etc/rc.d/init.d/vdsmd
280 # libvirtd upstart job is already configured on rhevh
281 sed -i 's/ && start_libvirtd$//' /etc/rc.d/init.d/vdsmd
283 # chkconfig results (symlinks) cannnot be peristed
284 sed -i 's#/sbin/chkconfig \$srv off##' /etc/rc.d/init.d/vdsmd
286 # reserve vdsm port 54321
287 augtool << \EOF_sysctl
288 set /files/etc/sysctl.conf/net.ipv4.ip_local_reserved_ports 54321
292 # rhbz#734478 add virt-who (*.py are removed in rhevh image)
293 cat > /usr/bin/virt-who <<EOF_virt_who
295 exec /usr/bin/python /usr/share/virt-who/virt-who.pyc "$@"
299 echo "* - maxlogins 3" >> /etc/security/limits.conf
302 patch -d /sbin -p0 << \EOF_mkdumprd
303 --- /sbin/mkdumprd.orig 2011-10-06 06:37:49.000000000 +0000
304 +++ /sbin/mkdumprd 2011-11-01 04:21:19.000000000 +0000
315 echo >> $MNTIMAGE/etc/ifcfg-$dev
316 echo "BUS_ID=\"Bonding\"" >> $MNTIMAGE/etc/ifcfg-$dev
320 for j in `ls /sys/class/net/$dev/brif`