diff -Nur e-smith-devtools-2.4.0.old.8951/CreateLinks.pm e-smith-devtools-2.4.0.8951/CreateLinks.pm --- e-smith-devtools-2.4.0.old.8951/CreateLinks.pm 2015-06-22 03:11:08.542436021 +0200 +++ e-smith-devtools-2.4.0.8951/CreateLinks.pm 2015-06-22 03:48:16.298307902 +0200 @@ -32,12 +32,15 @@ safe_symlink panel_link admin_common_link event_link service_link_enhanced safe_touch templates2events + event_templates event_actions event_services ); our %EXPORT_TAGS = ( all => [ qw!safe_symlink panel_link admin_common_link event_link service_link_enhanced - safe_touch templates2events! ] + safe_touch templates2events + event_templates event_actions event_services! ] ); + our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/; =head1 NAME @@ -192,6 +195,71 @@ } } +=head2 event_templates + +This function creates a file tree (of empty files) which is used by the +generic_template_expand action to determine which templates need to +be expanded for a particular event. Takes one event argument and a +list of file names, e.g. + + event_templates("$event", "/etc/some/file", "/etc/some/file2", "/etc/some/file3", ...); + +=cut + +sub event_templates +{ + my ($event, @paths) = @_; + + foreach (@paths) + { + safe_touch "root/etc/e-smith/events/$event/templates2expand/$_"; + } +} + +=head2 event_actions($event, %actions) + +Create links to actions for the given event. %actions is a list of pairs Action => Priority. E.g + + event_actions('myevent', 'action1' => '10', 'action2' => '20', ..); + +See also event_link(). + +=cut + +sub event_actions +{ + my ($event, %actions) = @_; + + foreach my $action (keys %actions) + { + my $level = $actions{$action}; + safe_symlink("../actions/${action}", + "root/etc/e-smith/events/${event}/S${level}${action}"); + } +} + +=head2 event_services($event, %services) + +Create links for the given $event in services2adjust/ +subdirectory. %services is a list of pairs Service => +LinkDestination + event_services('myevent', 'sshd' => 'restart', 'samba' => 'reload') +See also safe_symlink(). + +=cut + +sub event_services +{ + my ($event, %services) = @_; + + foreach my $service (keys %services) + { + my $action = $services{$service}; + safe_symlink($action, 'root/etc/e-smith/events/' . $event . '/services2adjust/' . $service); + } +} + + =head1 AUTHOR SME Server Developers