#!/bin/bash

. ${TOOLKIT}-functions.sh


# (MAIN)

# this is missing from veeam packages
#
enable_service veeamservice

# FIRST RUN?
#
# - install our custom cfg file
# - create default repository
# - create default job
#
file="ku-veeam.cfg"

# instead of automatically install our config file (from 'install' file)
# we install it manually, so we can use his existence to know if it is
# a fresh veeam installation
#
if [ -f /etc/veeam/$file ]
then
	# exists, but we install it anyway (needs to keep updated)
	installfile $file /etc/veeam/ root:root 660
else
	# do not exists, is a fresh veeam installation
	installfile $file /etc/veeam/ root:root 660

	echo -e "\n\tYOU NEED TO ACCEPT VEEAM LICENCE BEFORE PROCEED\n"
	confirm
	veeam

	veeam_create_default_repo
	veeam_create_default_job
fi



# cleanup
#
uninstallfiles --remove \
	/usr/sbin/veeam_add_default_job \
	/usr/sbin/veeam_run_default_job


$SOMETHING_CHANGED && {
	restart_service veeamservice veeamservice
}

exit 0
