Difference between revisions of "Createlinks example script"

From SME Server
Jump to navigationJump to search
Line 12: Line 12:
  
 
==== Example 1 ====  
 
==== Example 1 ====  
#!/usr/bin/perl -w
+
#!/usr/bin/perl -w
 
   
 
   
 
  sub safe_symlink {
 
  sub safe_symlink {

Revision as of 11:10, 20 December 2013

PythonIcon.png Skill level: Developer
Risk of inconsistencies with Koozali SME Server methodology, upgrades & functionality is high. One must be knowledgeable about how changes impact their Koozali SME Server. Significant risk of irreversible harm.


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

%build
perl createlinks

Example 1

#!/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");