ctdb-build: Enable some standard event scripts if none are enabled
authorMartin Schwenke <martin@meltin.net>
Sat, 7 Jul 2018 05:23:27 +0000 (15:23 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 11 Jul 2018 09:48:38 +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.

Only do this for a direct install.  If DESTDIR is being used then
assume a package is being built and let the packager handle this case.

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

index d306cb67e787660622867d3a00991ef5b82b5893..73fd5bd3d00fee337501905e6fdcd7b820aa8b27 100644 (file)
@@ -786,6 +786,25 @@ def build(bld):
             bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
                               destname=fmode[0], chmod=fmode[1])
 
+    # If this is a direct install and there are no event scripts
+    # linked/enabled then enable some standard ones
+    if os.environ.get('DESTDIR') is None:
+        fmt = 'events/legacy/%s.script'
+        required_script = '00.ctdb'
+        required_path = os.path.join(bld.env.CTDB_ETCDIR,
+                                     fmt % (required_script))
+        if not os.path.islink(required_path) and \
+           not os.path.exists(required_path):
+            default_scripts = [ required_script,
+                                '01.reclock',
+                                '05.system',
+                                '10.interface',
+                              ]
+            for t in default_scripts:
+                tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
+                name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
+                bld.symlink_as(name, tgt)
+
     bld.SAMBA_GENERATOR('ctdb-functions',
                         source='config/functions',
                         target='functions',