#!/bin/sh

set -e
set -x

if [ -n "${1}" ] ; then
	RELEASE=${1}
	shift
else
	RELEASE=buster
fi

if [ -n "${1}" ] ; then
	MIRROR_ADDR="${1}"
	shift
else
	MIRROR_ADDR=http://deb.debian.org/debian
fi

if [ -n "${1}" ] ; then
	SECURITY_MIRROR_ADDR=${1}
	shift
else
	SECURITY_MIRROR_ADDR=http://security.debian.org/debian-security
fi

HOOK_PATH=$(dirname $0)/manila-build-hook

build-openstack-debian-image --release ${RELEASE} --hook-script ${HOOK_PATH} \
	-u ${MIRROR_ADDR} \
	-s ${MIRROR_ADDR} \
	-e sudo,apt-transport-https,at,bash-completion,cloud-guest-utils,cron,curl,dbus,ifenslave,ifupdown,iptables,iputils-tracepath,irqbalance,less,lsof,net-tools,netbase,netcat-openbsd,open-vm-tools,pollinate,psmisc,rsyslog,socat,tcpdump,uuid-runtime,vim-tiny,vlan,debconf,dbconfig-common \
	--postinstall-packages haveged,joe,gpg,gpg-agent,dirmngr,iputils-ping,ethtool,gawk \
	--permit-ssh-as-root \
	--output debian-${RELEASE}-manila-$(TZ=UTC date '+%Y.%m.%d-%H.%M')-amd64 \
	--security-mirror ${SECURITY_MIRROR_ADDR}
