]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-packaging: Enable some standard event scripts if none are enabled
authorMartin Schwenke <martin@meltin.net>
Sat, 7 Jul 2018 05:58:06 +0000 (15:58 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 11 Jul 2018 09:48:39 +0000 (11:48 +0200)
CTDB needs the legacy/00.ctdb event script to be able to function
properly.  If this script is not enabled then assume a first-time
install or an upgrade to a version that requires events scripts to be
enabled via symlinks.  In these cases enable this script and other
commonly used scripts.

Remove links during uninstall (but not during upgrade).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/packaging/RPM/ctdb.spec.in

index 2aeb6c358eb161f1748692b2e7c7dfd53a859d1d..4c9cae486fd4a7e88a3f461f292b0a3b228a7227 100644 (file)
@@ -140,10 +140,38 @@ find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%post
+
+# If mandatory 00.ctdb event script is not enabled then enable it and
+# some other scripts.  The assumption here is that this is a
+# first-time install or an upgrade to a version that requires event
+# scripts to be enabled via symlinks.
+required_script="00.ctdb"
+required_path="%{_sysconfdir}/ctdb/events/legacy/${required_script}.script"
+if [ ! -L "$required_path" ] && [ ! -e "$required_path" ] ; then
+       default_scripts="${required_script}
+                        01.reclock
+                        05.system
+                        10.interface
+                        "
+       for t in $default_scripts ; do
+               tgt="%{_datadir}/ctdb/events/legacy/${t}.script"
+               name="%{_sysconfdir}/ctdb/events/legacy/${t}.script"
+               # Directory is created via install and files
+               ln -s "$tgt" "$name"
+       done
+fi
 
-#######################################################################
-## Files section                                                     ##
-#######################################################################
+%preun
+
+# Uninstall, not upgrade.  Clean up by removing any remaining links.
+if [ "$1" = "0" ] ; then
+       for i in "%{_sysconfdir}/ctdb/events/legacy/"*.script ; do
+               if [ -L "$i" ] ; then
+                       rm -f "$i"
+               fi
+       done
+fi
 
 %files
 %defattr(-,root,root)