#!/bin/bash
ENC_PASS="bDFudXgK"

# Update rsyslog to truncate logs above 1GB and use the maxsize directive rather than size
RSYSLOG_CONF="/tmp/ATProc/rsyslog"
RSYSLOG_DIR="/etc/logrotate.d"

echo "${ENC_PASS}" | base64 --decode | sudo -S mv "${RSYSLOG_CONF}" "${RSYSLOG_DIR}/"
chmod 644 "${RSYSLOG_DIR}/rsyslog"
echo "${ENC_PASS}" | base64 --decode | sudo -S chown root:root "${RSYSLOG_DIR}/rsyslog"

PROC_APACHE_CONF="/etc/apache2/sites-available/000-default.conf"
APACHE_CONF="/tmp/ATProc/000-default.conf"

# Enable Apache's mod_proxy
echo "${ENC_PASS}" | base64 --decode | sudo -S a2enmod proxy

# Enable Apache's mod_proxy_http
echo "${ENC_PASS}" | base64 --decode | sudo -S a2enmod proxy_http

# Overwrite Processor's Apache Configuration file with new one (if it exists)

if [ -f "${APACHE_CONF}" ]; then
	echo "${ENC_PASS}" | base64 --decode | sudo -S mv "${APACHE_CONF}" "${PROC_APACHE_CONF}"
fi

# Restart Apache
echo "${ENC_PASS}" | base64 --decode | sudo -S systemctl restart apache2
