#!/usr/bin/perl -w

use esmith::Build::CreateLinks qw(:all);

my $panel = "manager";
panel_link("clamav", $panel);


# For templates in all main events

foreach (qw(
            /etc/freshclam.conf
            /etc/clamd.d/scan.conf
            /etc/logrotate.d/clamd
            /etc/logrotate.d/clamav-update
            /etc/logrotate.d/freshclam
            /usr/lib/tmpfiles.d/clamd.conf
            /usr/lib/systemd/system/clamd.service.d/50koozali.conf
            ))
{
    templates2events("$_",qw(
	    post-install
	    post-upgrade
	    bootstrap-console-save
	    console-save
	    email-update
	    clamav-update
	    smeserver-clamav-update
	));
}

# For templates only in certain individual events

# Not required now
templates2events("/etc/cron.daily/freshclam", "bootstrap-console-save");
templates2events("/etc/cron.d/clamav-update", "bootstrap-console-save" );

my $event = "clamav-update";
templates2events("/etc/crontab", $event);
templates2events("/etc/systemd/system-preset/49-koozali.preset", $event );
templates2events("/etc/cron.daily/freshclam", $event );
templates2events("/etc/cron.d/clamav-update", $event );
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/clamd");


# clamav-update events
my $event = "smeserver-clamav-update";
templates2events("/etc/crontab", $event);
templates2events("/etc/systemd/system-preset/49-koozali.preset", $event );
templates2events("/etc/cron.daily/freshclam", $event );
templates2events("/etc/cron.d/clamav-update", $event );

safe_touch("root/etc/e-smith/templates/etc/cron.d/clamav-update");
event_link("systemd-default", $event, "88"); # updates all the service files etc
event_link("systemd-reload", $event, "89"); # systemctl daemon-reload
event_link("clamav-update", $event, "99"); 
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/clamd");
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/freshclam");

# email-update events - required?
$event = "email-update";
safe_symlink("reload", "root/etc/e-smith/events/$event/services2adjust/clamd");

exit 0;