diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-07-15 14:11:31 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-07-15 14:11:31 +0400 |
commit | 05ccd6cd08390fd4a53e389d46af7899d737a1ef (patch) | |
tree | 8ea26c361d16f86a7a0320523226868912da2437 | |
parent | 13f17a1b96c71792b18acf94b1f48379f803d850 (diff) | |
download | dh-smf-05ccd6cd08390fd4a53e389d46af7899d737a1ef.tar.gz |
Set upgrade policy in SMF manifests
Manifests will specify how to deal with a service on package upgrades:
stop - stop before removal old package, start after installing new one
restart - restart after upgrade (e. i. do not stop)
refresh - only refresh (e. g. for ssh)
none - do nothing
This is only applicable to daemons, e. i. not for 'transient' services.
-rwxr-xr-x | dh_smf | 47 |
1 files changed, 27 insertions, 20 deletions
@@ -54,26 +54,6 @@ Only modify F<postinst>/F<postrm>/F<prerm> scripts, do not actually install any files. May be useful if the file is shipped and/or installed by upstream in a way that doesn't make it easy to let B<dh_smf> find it. -=item B<-R>, B<--restart-after-upgrade> - -Do not stop the SMF service until after the package upgrade has been -completed. This is different than the default behavior, which stops the -service in the F<prerm>, and starts it again in the F<postinst>. - -This can be useful for daemons that should not have a possibly long -downtime during upgrade. But you should make sure that the daemon will not -get confused by the package being upgraded while it's running before using -this option. - -=item B<-r>, B<--no-restart-on-upgrade> - -Do not stop the SMF service on upgrade. - -=item B<--no-start> - -Do not start the service on install or upgrade. Maybe useful if -installing display managers like lightdm or GDM. - =back =head1 NOTES @@ -183,6 +163,9 @@ foreach my $package ( @{ $dh{DOPACKAGES} } ) { 'duration' => $xml->{'service'}->{'property_group'}->{'startd'}->{'propval'} ->{'duration'}->{'value'} // 'contract', + 'upgrade' => + $xml->{'service'}->{'property_group'}->{'package'} + ->{'propval'}->{'upgrade'}->{'value'} // 'stop', }; } if ( exists $xml->{'service'}->{'instance'} ) { @@ -197,6 +180,9 @@ foreach my $package ( @{ $dh{DOPACKAGES} } ) { 'duration' => $v->{'property_group'}->{'startd'}->{'propval'} ->{'duration'}->{'value'} // 'contract', + 'upgrade' => + $v->{'property_group'}->{'package'}->{'propval'} + ->{'upgrade'}->{'value'} // 'stop', }; } } @@ -207,6 +193,27 @@ foreach my $package ( @{ $dh{DOPACKAGES} } ) { my @pkg_manifests = map { s!\Q$tmp\E/*!/!; $_ } @manifests; autoscript( $package, 'postinst', 'postinst-smf-import', "s|#MANIFESTS#|@pkg_manifests|" ); + + my @daemons = grep { $_->{'duration'} ne 'transient' } @services; + my @daemons_stop = grep { $_->{'upgrade'} eq 'stop' } @daemons; + my @daemons_restart = grep { $_->{'upgrade'} eq 'restart' } @daemons; + my @daemons_refresh = grep { $_->{'upgrade'} eq 'refresh' } @daemons; + if (@daemons_stop) { + autoscript( $package, 'prerm', 'prerm-smf-stop', + "s|#DAEMONS#|@daemons_stop|" ); + autoscript( $package, 'postinst', 'postinst-smf-start', + "s|#DAEMONS#|@daemons_stop|" ); + } + if (@daemons_restart) { + autoscript( $package, 'postinst', 'postinst-smf-refresh', + "s|#DAEMONS#|@daemons_restart|" ); + autoscript( $package, 'postinst', 'postinst-smf-restart', + "s|#DAEMONS#|@daemons_restart|" ); + } + if (@daemons_refresh) { + autoscript( $package, 'postinst', 'postinst-smf-refresh', + "s|#DAEMONS#|@daemons_refresh|" ); + } } } |