Petr Šabata f5bf49
#!/usr/bin/env sh
Petr Šabata f5bf49
Petr Šabata f5bf49
# Executed before VM starts
Petr Šabata f5bf49
on_build() {
Petr Šabata f5bf49
	img_inst_pkg "nfs-utils dnsmasq"
Petr Šabata f5bf49
Petr Šabata f5bf49
	img_run_cmd "mkdir -p /srv/nfs/var/crash"
Petr Šabata f5bf49
	img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports"
Petr Šabata f5bf49
	img_run_cmd "systemctl enable nfs-server"
Petr Šabata f5bf49
DistroBaker 17a515
	img_run_cmd "touch /etc/systemd/resolved.conf"
DistroBaker 17a515
	img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf"
DistroBaker 17a515
Petr Šabata f5bf49
	img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf"
Petr Šabata f5bf49
	img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf"
Petr Šabata f5bf49
	img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf"
Petr Šabata f5bf49
	img_run_cmd "systemctl enable dnsmasq"
Petr Šabata f5bf49
Petr Šabata f5bf49
	img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0'
Petr Šabata f5bf49
	img_run_cmd 'echo BOOTPROTO="none >> /etc/sysconfig/network-scripts/ifcfg-eth0"'
Petr Šabata f5bf49
	img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
Petr Šabata f5bf49
	img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
Petr Šabata f5bf49
	img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
Petr Šabata f5bf49
	img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
Petr Šabata f5bf49
Petr Šabata f5bf49
	img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
# Executed when VM boots
Petr Šabata f5bf49
on_test() {
Petr Šabata f5bf49
	while true; do
Petr Šabata f5bf49
		if has_valid_vmcore_dir /srv/nfs/var/crash; then
Petr Šabata f5bf49
			# Wait a few seconds so client finish it's work to generate a full log
Petr Šabata f5bf49
			sleep 5
Petr Šabata f5bf49
Petr Šabata f5bf49
			test_passed
Petr Šabata f5bf49
		fi
Petr Šabata f5bf49
Petr Šabata f5bf49
		sleep 1
Petr Šabata f5bf49
	done
Petr Šabata f5bf49
}