#!/bin/bash

# Run triggers only on updates
if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
	exit
fi

if [ ! -e "/etc/hestiacp/hestia.conf" ]; then
	mkdir -p /etc/hestiacp
	echo -e "# Do not edit this file, will get overwritten on next upgrade, use /etc/hestiacp/local.conf instead\n\nexport HESTIA='/usr/local/hestia'\n\n[[ -f /etc/hestiacp/local.conf ]] && source /etc/hestiacp/local.conf" > /etc/hestiacp/hestia.conf
fi

# Configure apt to retry downloading on error
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
	echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
fi

# Validate version number and replace if different
HESTIA_V=$(dpkg -s hestia | grep -i version | awk '{ print $2 }')
