# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low
# Remediation is applicable only in certain platforms
if dpkg-query --show --showformat='${db:Status-Status}' 'auditd' 2>/dev/null | grep -q '^installed$' && dpkg-query --show --showformat='${db:Status-Status}' 'linux-base' 2>/dev/null | grep -q '^installed$'; then

if [ -e "/etc/audit/plugins.d/au-remote.conf" ] ; then
    
    LC_ALL=C sed -i "/^\s*active\s*=\s*/Id" "/etc/audit/plugins.d/au-remote.conf"
else
    touch "/etc/audit/plugins.d/au-remote.conf"
fi
# make sure file has newline at the end
sed -i -e '$a\' "/etc/audit/plugins.d/au-remote.conf"

cp "/etc/audit/plugins.d/au-remote.conf" "/etc/audit/plugins.d/au-remote.conf.bak"
# Insert at the end of the file
printf '%s\n' "active = yes" >> "/etc/audit/plugins.d/au-remote.conf"
# Clean up after ourselves.
rm "/etc/audit/plugins.d/au-remote.conf.bak"

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi