ovirt-node 2.2.0 release
[ovirt-node.git] / recipe / rhevh6-post.ks
blob301c8eae918592b568ff0b6b1818332f9432b546
1 # add RHEV-H rwtab locations
2 mkdir -p /rhev
3 mkdir -p /var/cache/rhn
4 cat > /etc/rwtab.d/rhev << EOF_RWTAB_RHEVH
5 empty   /rhev
6 files   /var/cache/rhn
7 files   /var/lib/vdsm
8 dirs    /var/db
9 dirs    /var/lib/rhsm
10 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
19 EOF_cron-rhn
21 # minimal lsb_release for vdsm-reg (bz#549147)
22 cat > /usr/bin/lsb_release <<\EOF_LSB
23 #!/bin/sh
24 if [ "$1" = "-r" ]; then
25     printf "Release:\t$(cat /etc/rhev-hypervisor-release | awk '{print $7}')\n"
26 else
27     echo RedHatEnterpriseVirtualizationHypervisor
29 EOF_LSB
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
35 EOF_CPE
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
40 @@ -13,7 +13,20 @@
41  _ = t.ugettext
42  import OpenSSL
43  import config
44 -from yum.Errors import RepoError
46 +class RepoError(Exception):
47 +    """
48 +    Base Yum Error. All other Errors thrown by yum should inherit from
49 +    this.
50 +    """
51 +    def __init__(self, value=None):
52 +        Exception.__init__(self)
53 +        self.value = value
54 +    def __str__(self):
55 +        return "%s" %(self.value,)
57 +    def __unicode__(self):
58 +        return '%s' % to_unicode(self.value)
60  class Error:
61      """base class for errors"""
62 EOF_up2date_patch2
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
68 @@ -73,10 +73,9 @@
69          return {}
71      try:
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")
77          conn = None
79      if not conn:
80 @@ -286,10 +285,10 @@
81          vdsm_enabled = True
83      # Crawl each of the domains on this host and obtain the new state.
84 -    if vdsm_enabled:
85 -        domain_list = poll_through_vdsm()
86 -    elif libvirt:
87 +    if libvirt:
88          domain_list = poll_hypervisor()
89 +    elif vdsm_enabled:
90 +        domain_list = poll_through_vdsm()
91      else:
92          # If no libvirt nor vdsm is present, this program is pretty much
93          # useless.  Just exit.
94 EOF_rhn_virt
95 python -m compileall /usr/share/rhn/virtualization
97 echo "Configuring SELinux"
98 # custom module for node specific rules
99 mkdir /tmp/SELinux
100 cd /tmp/SELinux
101 cat > ovirt.te << \EOF_OVIRT_TE
102 module ovirt 1.0;
103 require {
104     type initrc_t;
105     type initrc_tmp_t;
106     type mount_t;
107     type setfiles_t;
108     type shadow_t;
109     type unconfined_t;
110     class file { append mounton open getattr read execute ioctl lock entrypoint };
111     class fd { use };
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;
142 type ovirt_exec_t;
143 init_daemon_domain(unconfined_t,ovirt_exec_t)
144 EOF_OVIRT_TE
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)
148 EOF_OVIRT_FC
149 make NAME=targeted -f /usr/share/selinux/devel/Makefile
150 semodule -v -i ovirt.pp
151 cd /
152 rm -rf /tmp/SELinux
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
158 *filter
159 :INPUT ACCEPT [0:0]
160 :FORWARD ACCEPT [0:0]
161 :OUTPUT 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
165 # vdsm
166 -A INPUT -p tcp --dport 54321 -j ACCEPT
167 # libvirt tls
168 -A INPUT -p tcp --dport 16514 -j ACCEPT
169 # SSH
170 -A INPUT -p tcp --dport 22 -j ACCEPT
171 # guest consoles
172 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
173 # migration
174 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
175 # snmp
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
180 COMMIT
182 # configure IPv6 firewall, default is all ACCEPT
183 cat > /etc/sysconfig/ip6tables << \EOF
184 # oVirt automatically generated firewall configuration
185 *filter
186 :INPUT ACCEPT [0:0]
187 :FORWARD ACCEPT [0:0]
188 :OUTPUT 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
192 # libvirt tls
193 -A INPUT -p tcp --dport 16514 -j ACCEPT
194 # SSH
195 -A INPUT -p tcp --dport 22 -j ACCEPT
196 # guest consoles
197 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
198 # migration
199 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
200 # snmp
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
206 COMMIT
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
221 @@ -138,7 +138,7 @@
222      $"Unmounting pipe file systems (retry): " \
223      -f
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 \
230 EOF_halt
232 # rhbz#675868
233 # Modify rc.sysinit
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
237 @@ -43,7 +43,7 @@
238  fi
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
243  fi
245  disable_selinux() {
246 @@ -495,9 +495,9 @@
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
252  else
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
255  fi
257  # Update quotas if necessary
258 EOF_rc_sysinit
260 # rhbz#675868
261 # Modify start_udev
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
265 @@ -121,7 +121,7 @@
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
271         fi
273         if [ -x "$MAKEDEV" ]; then
274 EOF_start_udev
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
289 save
290 EOF_sysctl
292 # rhbz#734478 add virt-who (*.py are removed in rhevh image)
293 cat > /usr/bin/virt-who <<EOF_virt_who
294 #!/bin/sh
295 exec /usr/bin/python /usr/share/virt-who/virt-who.pyc "$@"
296 EOF_virt_who
298 # set maxlogins to 3
299 echo "*        -       maxlogins      3" >> /etc/security/limits.conf
301 # rhbz#738170
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
305 @@ -583,7 +583,7 @@
306          eth*.*)
307              modalias=8021q
308              ;;
309 -        br*)
310 +        rhevm|br*)
311              modalias=bridge
312              ;;
313          *)
314 @@ -756,7 +756,7 @@
315              echo >> $MNTIMAGE/etc/ifcfg-$dev
316              echo "BUS_ID=\"Bonding\"" >> $MNTIMAGE/etc/ifcfg-$dev
317              ;;
318 -       br*)
319 +       rhevm|br*)
320              for j in `ls /sys/class/net/$dev/brif`
321              do
322                  handlenetdev $j
324 EOF_mkdumprd