Createlinks example script
From SME Server
The build section lists commands to run as part of the build process This is where you can use a root/createlinks script to create events and action links. see
- Esmith::Build::CreateLinks
- SME_Server:Documentation:Developers_Manual#The_createlinks_script
- .spec_file_notes
%build perl createlinks
Example
#!/usr/bin/perl -w sub safe_symlink { my ($from, $to) = @_; use File::Basename; use File::Path; mkpath(dirname($to)); unlink($to); symlink($from, $to) or die "Can't create symlink from $from to $to: $!"; } sub panel_link { my ($function, $panel) = @_; safe_symlink("../../../functions/$function", "root/etc/e-smith/web/panels/$panel/cgi-bin/$function"); } sub event_link { my ($action, $event, $level) = @_; safe_symlink("../actions/${action}", "root/etc/e-smith/events/${event}/S${level}${action}"); } #-------------------------------------------------- # functions for manager panel #-------------------------------------------------- panel_link("yum", "manager"); #-------------------------------------------------- # actions for yum-update event #-------------------------------------------------- event_link("initialize-default-databases", "yum-update", "10"); event_link("conf-yum", "yum-update", "20"); event_link("yum-arch-repository", "yum-update", "30"); event_link("yum-check-repository", "yum-update", "40");
Example : Sme8admin
#! /usr/bin/perl -w use esmith::Build::CreateLinks qw(:all); # Start and stop links service_link_enhanced("sme8admind", "S99", "7"); service_link_enhanced("sme8admind", "K97", "6"); service_link_enhanced("sme8admind", "K20", "0"); service_link_enhanced("sme8admind", "K20", "1"); # Links for the panel panel_link("sme8admin", "manager"); #system("mkdir -p root/etc/e-smith/web/panels/manager/html/sme8admin"); safe_symlink("/etc/e-smith/web/panels/manager/html/sme8admin", "root/etc/e-smith/web/panels/user/html/sme8admin"); # Logrotate event_link("sme8admin-parselog","logrotate","15");
#!/usr/bin/perl -w use esmith::Build::CreateLinks qw(:all); #-------------------------------------------------- # functions for manager panel #-------------------------------------------------- my $panel = "manager"; panel_link("shares", $panel); panel_link("userpanel-encfs", $panel); #-------------------------------------------------- # actions for group-delete and user-delete events #-------------------------------------------------- foreach my $event (qw/group-delete user-delete/) { event_link("group-share-modify", $event, "10"); } #-------------------------------------------------- # actions for share-delete event #-------------------------------------------------- $event = "share-delete"; event_link("share-delete", $event, "15"); foreach my $event (qw(share-create share-modify share-modify-files)){ event_link("share-modify", $event, "15"); } foreach my $event (qw(share-create share-modify share-delete share-modify-servers)){ templates2events("/etc/samba/smb.conf", $event); templates2events("/etc/httpd/conf/httpd.conf", $event); templates2events("/etc/rsyncd.conf", $event); templates2events("/etc/proftpd.conf", $event); safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/smbd"); safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/rsyncd"); safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/ftp"); } #-------------------------------------------------- # actions for group-modify event #-------------------------------------------------- $event = 'group-modify'; templates2events("/etc/httpd/conf/httpd.conf", $event); safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); templates2events("/etc/fstab", "post-upgrade"); safe_touch("root/etc/e-smith/templates/etc/smb.conf/shares/template-begin"); safe_touch("root/var/service/rsyncd/down"); service_link_enhanced("rsyncd", "S95", "7"); service_link_enhanced("rsyncd", "K05", "6"); service_link_enhanced("rsyncd", "K05", "0"); safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/rsyncd'); safe_symlink("/var/service/rsyncd" , 'root/service/rsyncd'); templates2events("/etc/rsyncd.conf", "bootstrap-console-save"); templates2events("/etc/rsyncd.conf", "remoteaccess-update");
Example : denyhost
#!/usr/bin/perl -w use esmith::Build::CreateLinks qw(:all); panel_link("denyhosts", "manager"); service_link_enhanced("denyhosts", "S01", "7"); safe_symlink('restart', "root/etc/e-smith/events/conf-denyhosts/services2adjust/denyhosts"); foreach $file ( qw(/var/lib/denyhosts/allowed-hosts /etc/hosts.allow /etc/denyhosts.conf)) { templates2events($file, qw(bootstrap-console-save conf-denyhosts)); } exit 0;