#!/bin/sh

set -e
set -x

DIRNAME=$(dirname $0)

DEBIAN_RELEASE=${BODI_RELEASE}
OPENSTACK_RELEASE=rocky

# Add octavia's backport repo
echo "deb http://${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}.debian.net/debian ${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}-backports main
deb http://${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}.debian.net/debian ${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}-backports-nochange main
" >${BODI_CHROOT_PATH}/etc/apt/sources.list.d/${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}.list

wget http://${DEBIAN_RELEASE}-${OPENSTACK_RELEASE}.debian.net/debian/dists/pubkey.gpg -O ${BODI_CHROOT_PATH}/pubkey.gpg
chroot ${BODI_CHROOT_PATH} apt-key add /pubkey.gpg
chroot ${BODI_CHROOT_PATH} apt-get update

#cp ${BODI_CHROOT_PATH}/etc/cron.daily/logrotate ${BODI_CHROOT_PATH}/etc/cron.hourly
#mkdir -p ${BODI_CHROOT_PATH}/etc/systemd/system/logrotate.timer.d
#echo "[Timer]
#OnCalendar=hourly
#" >${BODI_CHROOT_PATH}/etc/systemd/system/logrotate.timer.d/hourly.conf

chroot ${BODI_CHROOT_PATH} apt-get install manila-agent

sed -i "s/\[global\]/\[global\]\\n\\n   include = registry\\n/g" ${BODI_CHROOT_PATH}/etc/samba/smb.conf
sed -i 's/\s&&\sgrep\s-q\s.*\s\$export_files$//g' ${BODI_CHROOT_PATH}/etc/init.d/nfs-kernel-server
