Difference between revisions of "ContribsUpdateEvent"

From SME Server
Jump to navigationJump to search
(uired)
Line 9: Line 9:
 
===For example===
 
===For example===
  
Installing
+
Installing smeserver-dhcpmanager, yum will look for and run an event that is called smeserver-dhcpmanager-update.
 +
 
 +
This is expected to be found in the events directory and take the usual event format of the sub directories "templates2expand" and "services2adjust" (if required) plus files for each action required.
 +
 
 +
[root@mailserver ~]# ls /etc/e-smith/events/smeserver-dhcpmanager-update
 +
S10systemd-default  S50systemd-reload  templates2expand
 +
[root@mailserver ~]#
 +
 
 +
yum will display a configuration and reboot required message if this directory does not exist.
 +
 
 +
===Using createlinks to create the -update event===
 +
 
 +
The normal way to create the -update event is to use the creatlinks file usually found on the top level of the data in the rpm. This is executed by a line in the spec file under the build directive:
 +
 
 +
%build
 +
perl createlinks
 +
 
 +
SME10 provides a perl package [https://wiki.koozali.org/Esmith::Build::CreateLinks esmith:Build:Createlinks] which does all the hard work of creating the events and other associated structures.
 +
 
 +
This is the top of a typical createlinks file:
 +
 
 +
#! /usr/bin/perl -w
 +
use esmith::Build::CreateLinks qw(:all);
 +
panel_link("dhcpd", "manager");
 +
 
 +
Note the panel link call to create an entry in the Server manager menu. This may not be required.
 +
 
 +
and the -update event is created as follows:
 +
 
 +
  # our event specific for updating with yum without reboot
 +
  $event = "smeserver-dhcpmanager-update";
 +
  #add here the path to your templates needed to expand
 +
  #see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event
 +
  foreach my $file (qw(
 +
                    /etc/systemd/system-preset/49-koozali.preset
 +
                    <other template expansion here>
 +
                  ))
 +
                  {templates2events( $file, $event );
 +
  }
 +
  #action needed in case we have a systemd unit
 +
  event_link("systemd-default", $event, "10");
 +
  event_link("systemd-reload", $event, "50");
 +
  #action specific to this package
 +
  #event_link("some event", $event, "30");
 +
  #services we need to restart
 +
  #safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/some service");
 +
 
 +
The Build:Createlinks package has other useful routines as well.
 +
 
 +
===Other ways to create the -update event===
 +
 
 +
In the extreme case where no action is required, but you want to suppress the post-upgrade;reboot message, the you can create the event directory using mkdir -p in the .spec file, but leave the contents empty. This can be done under the %setup directive as follows:
 +
 
 +
%setup
 +
%patch1 -p1
 +
...snip...
 +
%patch6 -p1
 +
mkdir -p root/etc/e-smith/events/smeserver-qmHandle-update
 +
 
 +
%build

Revision as of 10:03, 9 April 2021

Placeholder for Brian's page on the Update event for Contribs.

Background

For SME10 yum has been enhanced to look for an update event for an rpm that is being installed with the name <rpmname>-update. This is then run after the install, giving the developer the opportunity to configure the system and avoid the "post-upgrade;reboot" that has been needed in the past.

yum will suppress the "configure required" message if this event is found.

For example

Installing smeserver-dhcpmanager, yum will look for and run an event that is called smeserver-dhcpmanager-update.

This is expected to be found in the events directory and take the usual event format of the sub directories "templates2expand" and "services2adjust" (if required) plus files for each action required.

[root@mailserver ~]# ls /etc/e-smith/events/smeserver-dhcpmanager-update
S10systemd-default  S50systemd-reload  templates2expand
[root@mailserver ~]#

yum will display a configuration and reboot required message if this directory does not exist.

Using createlinks to create the -update event

The normal way to create the -update event is to use the creatlinks file usually found on the top level of the data in the rpm. This is executed by a line in the spec file under the build directive:

%build
perl createlinks

SME10 provides a perl package esmith:Build:Createlinks which does all the hard work of creating the events and other associated structures.

This is the top of a typical createlinks file:

#! /usr/bin/perl -w
use esmith::Build::CreateLinks qw(:all);
panel_link("dhcpd", "manager");

Note the panel link call to create an entry in the Server manager menu. This may not be required.

and the -update event is created as follows:

 # our event specific for updating with yum without reboot
 $event = "smeserver-dhcpmanager-update";
 #add here the path to your templates needed to expand
 #see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event
 foreach my $file (qw(
                   /etc/systemd/system-preset/49-koozali.preset
                   <other template expansion here>
                  ))
                 {templates2events( $file, $event );
 }
 #action needed in case we have a systemd unit
 event_link("systemd-default", $event, "10");
 event_link("systemd-reload", $event, "50");
 #action specific to this package
 #event_link("some event", $event, "30");
 #services we need to restart
 #safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/some service");

The Build:Createlinks package has other useful routines as well.

Other ways to create the -update event

In the extreme case where no action is required, but you want to suppress the post-upgrade;reboot message, the you can create the event directory using mkdir -p in the .spec file, but leave the contents empty. This can be done under the %setup directive as follows:

%setup
%patch1 -p1
...snip...
%patch6 -p1
mkdir -p root/etc/e-smith/events/smeserver-qmHandle-update
%build