Line 9: |
Line 9: |
| use esmith::Build::CreateLinks qw(:all); | | use esmith::Build::CreateLinks qw(:all); |
| safe_symlink("../../../functions/$function", "$cgibin/$function") | | safe_symlink("../../../functions/$function", "$cgibin/$function") |
| + | |
| + | the beginning is always the same. The createlinks is a file who add during the built of rpm all correct link to different events and services. |
| + | |
| + | #!/usr/bin/perl -w |
| + | use esmith::Build::CreateLinks qw(:all); |
| | | |
| ==== DESCRIPTION ==== | | ==== DESCRIPTION ==== |
Line 15: |
Line 20: |
| | | |
| ie. safe_symlink("../../../functions/$function", "$cgibin/$function") | | ie. safe_symlink("../../../functions/$function", "$cgibin/$function") |
| + | |
| + | * links to add (other templates are available in /etc/e-smith/templates-default/) |
| + | You don't have to create the file /etc/e-smith/templates/etc/test/db.php/template-begin, it is automatic if needed. You simply have to link to the correct template you want (it depends of your software language). You don't need this safe_symlink if the default template is correct for you. |
| + | safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/test/db.php/template-begin"); |
| + | safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/test/db.php/template-end"); |
| + | or another utilisation, do a link to an event already existing |
| + | '''existing event''' '''new event linked to the other event''' |
| + | safe_symlink("/etc/e-smith/events/bootstrap-console-save/templates2expand", "root/etc/e-smith/events/service-expand/templates2expand"); |
| + | |
| + | or if you want to do a link to an existing file |
| + | |
| + | '''existing file''' '''link in the rpm''' |
| + | safe_symlink("/usr/share/php/Net/LDAP3","root/usr/share/pear/Net/LDAP3"); |
| + | safe_symlink("/usr/share/php/Net/LDAP3.php","root/usr/share/pear/Net/LDAP3.php"); |
| + | |
| + | |
| + | * service to restart on demand |
| + | |
| + | for my $event (qw( |
| + | conf-roundcube |
| + | )) |
| + | { |
| + | templates2events("/etc/httpd/conf/httpd.conf", $event); #####expand-template on event conf-roundcube |
| + | safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init"); #####restart mysqlinit on event conf-roundcube |
| + | safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); #####restart httpd on event conf-roundcube |
| + | } |
| | | |
| ===== panel_link ===== | | ===== panel_link ===== |
Line 22: |
Line 53: |
| my $panel = "manager"; | | my $panel = "manager"; |
| panel_link("tug", $panel); | | panel_link("tug", $panel); |
| + | |
| + | ie : |
| + | panel_link("denyhosts", "manager"); |
| | | |
| ===== admin_common_link ===== | | ===== admin_common_link ===== |
Line 27: |
Line 61: |
| | | |
| ===== event_link ===== | | ===== event_link ===== |
− | This function creates a symlink from an action’s ordered location in an event directory to its action script. | + | This function creates a symlink from an action’s ordered location in an event directory to its action script. (actions are in /etc/e-smith/events/actions/) |
| | | |
| ie. | | ie. |
Line 35: |
Line 69: |
| event_link("adjust-masq", $event, "30"); | | event_link("adjust-masq", $event, "30"); |
| event_link("tug-restart", $event, "40"); | | event_link("tug-restart", $event, "40"); |
| + | or |
| + | foreach my $event (qw/webapps-update ipasserelle-update bootstrap-ldap-save/){ |
| + | event_link("phplist-create-pseudo", "$event", "55"); |
| + | } |
| + | |
| + | |
| + | * Order of implicit actions |
| + | |
| + | The implicit actions are implemented by inserting the action script generic_template_expand early in the list of actions to be run in an event and the adjust-services action near the end of the list. You should normally link your action scripts in the range S10 to S80 so that they occur after templates2expand and before services2adjust. |
| + | |
| + | {{Note box|The generic_template_expand action is currently run at S05 and services2adjust is run at S90.}} |
| | | |
| ===== service_link_enhanced ===== | | ===== service_link_enhanced ===== |
Line 44: |
Line 89: |
| service_link_enhanced("tug", "K25", "6"); | | service_link_enhanced("tug", "K25", "6"); |
| service_link_enhanced("tug", "K25", "0"); | | service_link_enhanced("tug", "K25", "0"); |
| + | safe_symlink("/var/service/tug/", "root/service/tug"); |
| + | |
| + | of course the job script needs to be in /var/service/tug (should be relevant that it needs to be named by the same name : tug) |
| | | |
| ===== safe_touch ===== | | ===== safe_touch ===== |
| | | |
| This function creates an empty file, but first creates any enclosing directories. For example: | | This function creates an empty file, but first creates any enclosing directories. For example: |
| + | |
| + | ie : |
| + | safe_touch("root/var/lib/phplist/bounces.mbox"); |
| | | |
| ===== safe_touch("a/b/c/d"); ===== | | ===== safe_touch("a/b/c/d"); ===== |
Line 57: |
Line 108: |
| | | |
| templates2events("/etc/some/file", "event1", "event2", ...); | | templates2events("/etc/some/file", "event1", "event2", ...); |
| + | |
| + | eg : |
| + | |
| + | 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); |
| + | } |
| + | could be written like that also |
| + | |
| + | templates2events("/etc/e-smith/sql/init/phplistdb", qw/webapps-update bootstrap-console-save/); |
| + | templates2events("/etc/phplist/config.php", qw/webapps-update bootstrap-console-save/); |
| + | |
| + | or more simply |
| + | |
| + | templates2events("/opt/roundcube/config/db.inc.php", console-save); |
| + | |
| + | {{Note box|msg=The settings below are new, waiting a release with the bug [[bugzilla: 8951]]}} |
| + | |
| + | ===== 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", ...); |
| + | |
| + | # templates to expand |
| + | for my $event (qw( |
| + | conf-wordpress |
| + | wordpress-update |
| + | )) |
| + | { |
| + | event_templates ($event , "/etc/httpd/conf/httpd.conf"); |
| + | event_templates ($event , "/etc/dar/DailyBackup.dcf"); |
| + | } |
| + | |
| + | ===== 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(). |
| + | |
| + | # actions to perform |
| + | for my $event (qw( |
| + | bootstrap-console-save |
| + | console-save |
| + | conf-wordpress |
| + | wordpress-update |
| + | )) |
| + | { |
| + | event_actions ( $event , 'wordpress' => '20', 'wordpressa' => '30' , 'wordpressb' => '40'); |
| + | } |
| + | ===== 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(). |
| + | |
| + | # services to launch on event |
| + | for my $event (qw( |
| + | conf-wordpress |
| + | wordpress-update |
| + | )) |
| + | { |
| + | event_services ( $event , "httpd-e-smith"=> 'sigusr1'); |
| + | event_services ( $event , "mysql.init"=> 'restart'); |
| + | } |
| | | |
| ==== AUTHOR ==== | | ==== AUTHOR ==== |
| SME Server Developers <bugs@e-smith.com> | | SME Server Developers <bugs@e-smith.com> |
− | | + | ==== SEE ALSO ==== |
| + | *[[SME_Server:Documentation:Developers_Manual#The_createlinks_script]] |
| + | *[[.spec_file_notes]] |
| + | *[[Createlinks_example_script]] |
| | | |
| [[Category:SME Server Development Framework]] | | [[Category:SME Server Development Framework]] |
| [[Category:Development Tools]] | | [[Category:Development Tools]] |
− | [[Category:SME9-Development]]
| |