azure.conf revision 277458
1273076Sgjb#!/bin/sh
2273076Sgjb#
3273076Sgjb# $FreeBSD: head/release/tools/azure.conf 277458 2015-01-20 23:56:04Z gjb $
4273076Sgjb#
5273076Sgjb
6273076Sgjb# Set to a list of packages to install.
7273076Sgjb# Example:
8273076Sgjb#export VM_EXTRA_PACKAGES="www/apache24"
9277458Sgjbexport VM_EXTRA_PACKAGES="sysutils/azure-agent"
10273076Sgjb
11273076Sgjb# Set to a list of third-party software to enable in rc.conf(5).
12273076Sgjb# Example:
13273076Sgjb#export VM_RC_LIST="apache24"
14273096Sgjbexport VM_RC_LIST=
15277458Sgjb
16277458Sgjbvm_extra_pre_umount() {
17277458Sgjb	chroot ${DESTDIR} /usr/sbin/waagent -verbose -install
18277458Sgjb	yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision
19277458Sgjb	echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
20277458Sgjb	echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
21277458Sgjb	echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
22277458Sgjb	echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
23277458Sgjb	echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
24277458Sgjb
25277458Sgjb	rm -f ${DESTDIR}/etc/resolv.conf
26277458Sgjb
27277458Sgjb	return 0
28277458Sgjb}
29277458Sgjb
30277458Sgjbvm_extra_create_disk() {
31277458Sgjb	if [ ! -x "/usr/local/bin/qemu-img" ]; then
32277458Sgjb		env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel
33277458Sgjb	fi
34277458Sgjb
35277458Sgjb	mv ${VMIMAGE} ${VMIMAGE}.raw
36277458Sgjb	size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',')
37277458Sgjb	size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) ))
38277458Sgjb	qemu-img resize ${VMIMAGE}.raw ${size}
39277458Sgjb	qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE}
40277458Sgjb
41277458Sgjb	return 0
42277458Sgjb}
43