1 # ovirt-install-node-stateless
2 # ovirt_setup_libvirtd()
3 # just to get a boot warning to shut up
6 # make libvirtd listen on the external interfaces
7 sed -i -e 's/^#\(LIBVIRTD_ARGS="--listen"\).*/\1/' \
8 /etc/sysconfig/libvirtd
10 # set up qemu daemon to allow outside VNC connections
11 sed -i -e 's/^[[:space:]]*#[[:space:]]*\(vnc_listen = "0.0.0.0"\).*/\1/' \
12 /etc/libvirt/qemu.conf
13 # set up libvirtd to listen on TCP (for kerberos)
14 sed -i -e "s/^[[:space:]]*#[[:space:]]*\(listen_tcp\)\>.*/\1 = 1/" \
15 -e "s/^[[:space:]]*#[[:space:]]*\(listen_tls\)\>.*/\1 = 0/" \
16 /etc/libvirt/libvirtd.conf
18 #ovirt_setup_anyterm()
20 cat >> /etc/sysconfig/anyterm << \EOF_anyterm
21 ANYTERM_CMD="sudo /usr/bin/virsh console %p"
22 ANYTERM_LOCAL_ONLY=false
25 # permit it to run the virsh console
26 echo "anyterm ALL=NOPASSWD: /usr/bin/virsh console *" >> /etc/sudoers
28 # systemd configuration
29 # set default runlevel to multi-user(3)
31 rm -rf /etc/systemd/system/default.target
32 ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
34 # setup ovirt-firstboot multi-user dependency
35 cat >> /lib/systemd/system/ovirt-firstboot.service << \EOF_firstboot
37 Description=firstboot configuration program (text mode)
38 After=plymouth-quit.service
39 Before=getty@tty1.service
42 Environment=RUNLEVEL=3
43 ExecStartPre=-/bin/plymouth quit
44 ExecStart=/etc/init.d/ovirt-firstboot start
49 StandardInput=tty-force
52 WantedBy=multi-user.target
55 systemctl enable ovirt-firstboot.service >/dev/null 2>&1
56 chkconfig --del ovirt-firstboot
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
66 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
67 -A INPUT -p icmp -j ACCEPT
68 -A INPUT -i lo -j ACCEPT
70 -A INPUT -p tcp --dport 22 -j ACCEPT
72 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
74 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
76 -A INPUT -p udp --dport 161 -j ACCEPT
78 -A INPUT -j REJECT --reject-with icmp-host-prohibited
79 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp-host-prohibited
82 # configure IPv6 firewall, default is all ACCEPT
83 cat > /etc/sysconfig/ip6tables << \EOF
84 # oVirt automatically generated firewall configuration
89 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
90 -A INPUT -p ipv6-icmp -j ACCEPT
91 -A INPUT -i lo -j ACCEPT
93 -A INPUT -p tcp --dport 22 -j ACCEPT
95 -A INPUT -p tcp -m multiport --dports 5634:6166 -j ACCEPT
97 -A INPUT -p tcp -m multiport --dports 49152:49216 -j ACCEPT
99 -A INPUT -p udp --dport 161 -j ACCEPT
100 # unblock ipv6 dhcp response
101 -A INPUT -p udp --dport 546 -j ACCEPT
102 -A INPUT -j REJECT --reject-with icmp6-adm-prohibited
103 -A FORWARD -m physdev ! --physdev-is-bridged -j REJECT --reject-with icmp6-adm-prohibited
107 python -m compileall /usr/share/virt-manager
109 echo "Configuring SELinux"
110 # custom module for node specific rules
113 cat > ovirt.te << \EOF_OVIRT_TE
122 class file { append mounton open getattr read execute ioctl lock entrypoint };
124 class process { sigchld signull transition noatsecure siginh rlimitinh getattr };
125 class fifo_file { getattr open read write append lock ioctl };
126 class filesystem getattr;
127 class dir { getattr search open read lock ioctl };
128 class socket { read write };
129 class tcp_socket { read write };
130 class udp_socket { read write };
131 class rawip_socket { read write };
132 class netlink_socket { read write };
133 class packet_socket { read write };
134 class unix_stream_socket { read write create ioctl getattr lock setattr append bind connect getopt setopt shutdown connectto };
135 class unix_dgram_socket { read write };
136 class appletalk_socket { read write };
137 class netlink_route_socket { read write };
138 class netlink_firewall_socket { read write };
139 class netlink_tcpdiag_socket { read write };
140 class netlink_nflog_socket { read write };
141 class netlink_xfrm_socket { read write };
142 class netlink_selinux_socket { read write };
143 class netlink_audit_socket { read write };
144 class netlink_ip6fw_socket { read write };
145 class netlink_dnrt_socket { read write };
146 class netlink_kobject_uevent_socket { read write };
147 class tun_socket { read write };
148 class chr_file { getattr read write append ioctl lock open };
149 class lnk_file { getattr read };
150 class sock_file { getattr write open append };
152 allow mount_t shadow_t:file mounton;
153 allow setfiles_t initrc_tmp_t:file append;
155 init_daemon_domain(unconfined_t,ovirt_exec_t)
157 cat > ovirt.fc << \EOF_OVIRT_FC
158 /etc/rc\.d/init\.d/ovirt-firstboot -- gen_context(system_u:object_r:ovirt_exec_t)
159 /etc/rc\.d/init\.d/ovirt-post -- gen_context(system_u:object_r:ovirt_exec_t)
161 make NAME=targeted -f /usr/share/selinux/devel/Makefile
162 semodule -v -i ovirt.pp
166 # Workaround for rhbz#755464
167 /sbin/service zfs-fuse stop 2>/dev/null