source /usr/share/makepkg/util/message.sh

post_install() {

  if [[ ! -d /var/lib/cloudstack/user ]]; then
    mkdir -p /var/lib/cloudstack/user
    chown cloud.cloud -R /var/lib/cloudstack/user
  fi

  chown cloud.cloud /var/log/cloudstack
#  chown cloud.cloud /run/cloudstack-management.pid

  # Apply cloudbr0 & cloudbr1 network interfaces
  systemctl restart systemd-networkd 
  systemctl restart mysqld

  msg2 "Configuration info: http://docs.cloudstack.apache.org/en/latest/installguide/management-server/"

  msg2 "System VM template files are located at '/usr/share/cloudstack-management/templates/systemvm/'"
  msg2 "Install it by issuing command: sudo /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -o localhost -r cloud -d cloud -h kvm -f /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.16.0-kvm.qcow2.bz2 -m <secondary-storage-mountpoint>"

  msg2 "Generate proper encryption file (/etc/cloudstack/management/key): sudo cloudstack-setup-encryption -e file -m <password> -k <password>"

  msg2 "Configure local database: sudo cloudstack-setup-databases cloud:cloud@localhost --deploy-as=root:<mysql-root-password>"

  msg2 "http://localhost:8080 default login credentials are -> username: admin, password: <password> (used for /etc/cloudstack/management/key), domain: leave empty"
}

#post_upgrade() {
#}

#post_remove() {
#  rm -rf /var/lib/cloudstack/user
#}