ctdb-scripts: Properly set CTDB_VARDIR in scripts at install time
authorMartin Schwenke <martin@meltin.net>
Thu, 13 Aug 2015 05:17:51 +0000 (15:17 +1000)
committerMichael Adam <obnox@samba.org>
Tue, 15 Sep 2015 06:56:21 +0000 (08:56 +0200)
Have wscript do path substitution.

No need to export this and CTDB_ETCDIR here, but test scripts will
still need to do so.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/config/functions
ctdb/doc/ctdbd.1.xml
ctdb/doc/ctdbd.conf.5.xml
ctdb/wscript

index 66140dc1aa00bb15e7fd9eabd6bbb776e9310e3e..9711c516deefef88dbb60a9b7367644206e3ab12 100755 (executable)
@@ -2,16 +2,15 @@
 
 # utility functions for ctdb event scripts
 
-[ -z "$CTDB_VARDIR" ] && {
-    if [ -d "/var/lib/ctdb" ] ; then
-       export CTDB_VARDIR="/var/lib/ctdb"
-    else
-       export CTDB_VARDIR="/var/ctdb"
-    fi
-}
-[ -z "$CTDB_ETCDIR" ] && {
-    export CTDB_ETCDIR="/etc"
-}
+# Only (and always) override these variables in test code
+
+if [ -z "$CTDB_VARDIR" ] ; then
+    CTDB_VARDIR="/usr/local/var/lib/ctdb"
+fi
+
+if [ -z "$CTDB_ETCDIR" ] ; then
+    CTDB_ETCDIR="/etc"
+fi
 
 #######################################
 # pull in a system config file, if any
index 7a3844bafdec46dd648e61508b845318541affa3..8f6b7c9ac5f743af051d0a628a09b9337aca7768 100644 (file)
@@ -72,7 +72,7 @@
            should not be stored on the shared cluster filesystem.
          </para>
          <para>
-           This directory would usually be <filename>/var/lib/ctdb</filename>
+           Defaults to <filename>/usr/local/var/lib/ctdb</filename>.
          </para>
        </listitem>
       </varlistentry>
@@ -87,8 +87,7 @@
            filesystem.
          </para>
          <para>
-           This directory would usually be
-           <filename>/var/lib/ctdb/persistent</filename>
+           Defaults to <filename>/usr/local/var/lib/ctdb/persistent</filename>.
          </para>
        </listitem>
       </varlistentry>
            should not be stored on the shared cluster filesystem.
          </para>
          <para>
-           This directory would usually be
-           <filename>/var/lib/ctdb/state</filename>
+           Defaults to <filename>/usr/local/var/lib/ctdb/state</filename>.
          </para>
        </listitem>
       </varlistentry>
index f45c724f4b5413d4e90b13ffc9c24536e6592c40..da2471e8e29ef0726914abbd37dc02ea3e303c7e 100644 (file)
            runtime.
          </para>
          <para>
-           Defaults to <filename>/var/ctdb</filename>, unless
-           <filename>/var/lib/ctdb</filename> already exists in which
-           case it is used.
+           Defaults to <filename>/usr/local/var/lib/ctdb</filename>.
          </para>
        </listitem>
       </varlistentry>
        <term>CTDB_DBDIR=<parameter>DIRECTORY</parameter></term>
        <listitem>
          <para>
-           Defaults to <varname>CTDB_VARDIR</varname>.  Corresponds to
-           <option>--dbdir</option>.
+           Defaults to <filename>/usr/local/var/lib/ctdb</filename>.
+         </para>
+         <para>
+           Corresponds to <option>--dbdir</option>.
          </para>
        </listitem>
       </varlistentry>
        <term>CTDB_DBDIR_PERSISTENT=<parameter>DIRECTORY</parameter></term>
        <listitem>
          <para>
-           Defaults to <varname>CTDB_VARDIR</varname>/persistent.
+           Defaults to <filename>/usr/local/var/lib/ctdb/persistent</filename>.
+         </para>
+         <para>
            Corresponds to <option>--dbdir-persistent</option>.
          </para>
        </listitem>
        <term>CTDB_DBDIR_STATE=<parameter>DIRECTORY</parameter></term>
        <listitem>
          <para>
-           Defaults to <varname>CTDB_VARDIR</varname>/state.
+           Defaults to <filename>/usr/local/var/lib/ctdb/state</filename>.
+         </para>
+         <para>
            Corresponds to <option>--dbdir-state</option>.
          </para>
        </listitem>
index 7f3b9e7e15d88a700c0c90dd5bbca0037dfab74c..c8dd44e43662bd8d8316f22be3693b08b0ccb596 100755 (executable)
@@ -36,6 +36,19 @@ samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
                         lib/ccan:lib/ccan libcli/util:libcli/util
                         buildtools:buildtools third_party/waf:third_party/waf''')
 
+manpages = [
+    'ctdb.1',
+    'ctdb.7',
+    'ctdbd.1',
+    'ctdbd.conf.5',
+    'ctdbd_wrapper.1',
+    'ctdb-statistics.7',
+    'ctdb-tunables.7',
+    'ltdbtool.1',
+    'onnode.1',
+    'ping_pong.1'
+]
+
 
 def set_options(opt):
     opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
@@ -356,7 +369,7 @@ def build(bld):
                              ctdb-common-util ctdb-system ctdb-tcp''' +
                           ib_deps,
                      install_path='${SBINDIR}',
-                     manpages='doc/ctdbd.1')
+                     manpages='ctdbd.1')
 
     bld.SAMBA_BINARY('ctdb',
                      source='tools/ctdb.c tools/ctdb_vacuum.c',
@@ -364,14 +377,14 @@ def build(bld):
                              ctdb-system''',
                      includes='include include/internal',
                      install_path='${BINDIR}',
-                     manpages='doc/ctdb.1')
+                     manpages='ctdb.1')
 
     bld.SAMBA_BINARY('ltdbtool',
                      source='tools/ltdbtool.c',
                      includes='include',
                      deps='tdb',
                      install_path='${BINDIR}',
-                     manpages='doc/ltdbtool.1')
+                     manpages='ltdbtool.1')
 
     bld.SAMBA_BINARY('ctdb_lock_helper',
                      source='server/ctdb_lock_helper.c',
@@ -413,7 +426,7 @@ def build(bld):
                      source='utils/ping_pong/ping_pong.c',
                      deps='',
                      install_path='${BINDIR}',
-                     manpages='doc/ping_pong.1')
+                     manpages='ping_pong.1')
 
     if bld.env.HAVE_PMDA:
         bld.SAMBA_BINARY('pmdactdb',
@@ -435,10 +448,20 @@ def build(bld):
         bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
                           destname='README')
 
+    sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g'  % (bld.env.CTDB_VARDIR)
+    sed_cmdline = '-e "%s"' % (sed_expr1)
+
+    for f in manpages:
+        x = '%s.xml' % (f)
+        bld.SAMBA_GENERATOR(x,
+                            source=os.path.join('doc', x),
+                            target=x,
+                            rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+
     if 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
-        bld.MANPAGES('''doc/onnode.1 doc/ctdbd_wrapper.1 doc/ctdbd.conf.5
-                        doc/ctdb.7 doc/ctdb-statistics.7 doc/ctdb-tunables.7''',
-                     True)
+        bld.MANPAGES('''onnode.1 ctdbd_wrapper.1 ctdbd.conf.5
+                        ctdb.7 ctdb-statistics.7 ctdb-tunables.7''',
+                      True)
 
     bld.INSTALL_FILES('${BINDIR}', 'tools/onnode',
                       destname='onnode', chmod=0755)
@@ -478,8 +501,11 @@ def build(bld):
             bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
                               destname=fmode[0], chmod=fmode[1])
 
-    bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
-                      destname='functions')
+    bld.SAMBA_GENERATOR('ctdb-functions',
+                        source='config/functions',
+                        target='functions',
+                        rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+    bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
 
     etc_scripts = [
         'ctdb-crash-cleanup.sh',
@@ -689,19 +715,6 @@ def dist():
         sys.exit(ret)
     samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
 
-    manpages = [
-        'ctdb.1',
-        'ctdb.7',
-        'ctdbd.1',
-        'ctdbd.conf.5',
-        'ctdbd_wrapper.1',
-        'ctdb-statistics.7',
-        'ctdb-tunables.7',
-        'ltdbtool.1',
-        'onnode.1',
-        'ping_pong.1'
-    ]
-
     cmd = 'make -C doc'
     ret = samba_utils.RUN_COMMAND(cmd)
     if ret != 0: