File: //var/lib/cloud/scripts/per-once/cpanel_init.sh
#!/bin/bash
#Clean cpanel history
rm -rf /var/cpanel/user_notifications/root/history/*
rm -rf /var/cpanel/userhomes/cpanel/mail/new/*
#Delete DNS Zone of packer install
/scripts/killdns packer.cpanel.ovh
#Reset /etc/wwwacct.conf
sed -i '/^ADDR/d' /etc/wwwacct.conf
sed -i '/^NS/d' /etc/wwwacct.conf
sed -i '/^HOST/d' /etc/wwwacct.conf
echo "ADDR $(hostname -I|awk '{print $1}')" >> /etc/wwwacct.conf
echo "HOST $(hostname -f)" >> /etc/wwwacct.conf
echo "NS $(hostname -f)" >> /etc/wwwacct.conf
echo "NS2 cdns.ovh.net" >> /etc/wwwacct.conf
#Clean up /etc/hosts
sed -i '/packer/d' /etc/hosts
#Update cpanel
/usr/local/cpanel/scripts/upcp
#Run cpanel NAT
/scripts/build_cpnat
#Generate url and print in console-log
url=$(whmlogin)
echo -e '\n\n\nOVH_OUTPUT:[{"type":"cpanel","url":"'"$url"'"}]\n\n\n' >> /dev/ttyS0