1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

631 Commits

Author SHA1 Message Date
Martin Schwenke
ac1c12b5a2 ctdb-scripts: Use load_script_options() in miscellaneous scripts
Some of these just aim to load the generic script.options file while
others target more specific files.

For NFS configuration, always use 60.nfs.options - even for 06.nfs.
This could be carefully documented but will change a lot before
release so there is no need.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-05-12 06:11:17 +02:00
Martin Schwenke
130f37c23f ctdb-scripts: Don't check for CTDB_PARTIALLY_ONLINE_INTERFACES clash
Just document that NAT gateway and LVS are not compatible with this
option.  Update the documentation to make it clear that this is a
10.interface option.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-05-12 06:11:17 +02:00
Martin Schwenke
051203e1f8 ctdb-scripts: Fix location of persistent databases
If CTDB_DBDIR_PERSISTENT is not set then set the default relative to
CTDB_VARDIR.  The persistent database directory is not (necessarily)
relative to the volatile one.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-05-01 13:31:20 +02:00
Martin Schwenke
26430ab1d1 ctdb-scripts: Drop unused variable service_config
This was previously used by the loadconfig() function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-04-27 06:53:16 +02:00
Martin Schwenke
d8741feec5 ctdb-scripts: Avoid shellcheck SC1117: Backslash is literal in "..."
This warning (apparently new in shellcheck 0.4.7) only applies to
double-quoted strings.  Change affected constant strings to use
single-quotes.  In the one example that contains a variable expansion
escape the backslash as recommended.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-04-27 06:53:16 +02:00
Amitay Isaacs
6b75d2c650 ctdb-scripts: Drop "net serverid wipe" from 50.samba event script
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13359

There is no serverid database anymore.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sat Mar 31 08:34:00 CEST 2018 on sn-devel-144
2018-03-31 08:34:00 +02:00
Martin Schwenke
02fc52d69b ctdb-scripts: Tunables are now loaded from ctdb.tunables
Using CTDB_SET_TunableVariables in the main configuration file is no
longer supported.

The only subtlety is an unexpected order change in one of the unit
test results.  This is because the old implementation implicitly
sorted the tunable variables via the set command.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28 02:57:21 +02:00
Martin Schwenke
65ce5e2129 ctdb-scripts: Use load_script_options in event scripts
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28 02:57:21 +02:00
Martin Schwenke
b499775527 ctdb-scripts: Split CTDB configuration loading
loadconfig() currently tries to load the CTDB configuration and also
any system configuration relevant to the current (event) script.

Instead add a new function load_system_config() to load the
distribution-specific system configuration for a component.  Call this
directly in the rare scripts that need the system configuration.

Also call load_system_config when loading the CTDB configuration to
pull in anything from the CTDB system configuration.  This is partly
for backward compatibility but also to get options that can be used
anywhere.

loadconfig() no longer takes an argument.  It simply loads the CTDB
configuration.

Drop support for falling back to /etc/ctdb/sysconfig/ctdb (or
similar).  Surely there's nobody who uses that!

Also, drop the indirection where loadconfig() calls _loadconfig().
This was used years ago as a test hook and is no longer required.

Inexplicably, this change introduces a new shellcheck test failure, so
silence this.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28 02:57:20 +02:00
Martin Schwenke
2f33b18d84 ctdb-script: Drop CTDB_MANAGED_SERVICES configuration option
This seems never to have caught on so reduce complexity.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28 02:57:15 +02:00
Martin Schwenke
b1fcb0a129 ctdb-scripts: Drop CTDB_PUBLIC_INTERFACE configuration option
The interface must always be specified in the public addresses file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19 02:23:19 +01:00
Martin Schwenke
6ecddd4f72 ctdb-scripts: Drop CTDB_PUBLIC_ADDRESSES configuration option
This option adds a lot of unnecessary complexity to scripts.
Configuration should go in $CTDB_BASE, either directly or via a
symlink, so simplify by using the default location.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19 02:23:19 +01:00
Martin Schwenke
a757182134 ctdb-scripts: Drop 10.external event script
This was added for a vendor who decided not to use it.  It is almost
certainly unused by anyone.  If anyone really needs it then it is in
the git history.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19 02:23:19 +01:00
Martin Schwenke
b416ed72d4 ctdb-scripts: Simplify the names of NFS fail counter files
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:24 +01:00
Martin Schwenke
bcadab7149 ctdb-scripts: Move failure counters to the service state directory
Scripts that use these counters must call ctdb_setup_state_dir().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:24 +01:00
Martin Schwenke
e6aae12ba2 ctdb-scripts: Move the reconfigure flag to the script state directory
Scripts that use these functions must call ctdb_setup_state_dir().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:24 +01:00
Martin Schwenke
eed0e3f6d7 ctdb-scripts: Use ctdb_setup_state_dir()
Replace all uses of ctdb_setup_service_state_dir() by
ctdb_setup_state_dir().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:24 +01:00
Martin Schwenke
c8dfd4fe5a ctdb-scripts: Add default for public addresses file where missing
This makes it consistent with the rest of the script code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01 19:39:14 +01:00
Martin Schwenke
0519c513ad ctdb-scripts: Do not use ctdb_service_reconfigure() for policy routing
This is an unconditional reconfiguration so skip the unnecessary
logic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01 19:39:14 +01:00
Amitay Isaacs
7720ca0729 ctdb-common: Ignore event scripts with multiple '.'s
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13070

This avoids running event script copies left by a package manager.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2017-10-18 06:20:18 +02:00
Martin Schwenke
507c81a739 ctdb-scripts: Fix a typo
This is a regression introduced in commit
e847ec3ae2

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-07-23 15:38:10 +02:00
Martin Schwenke
4e68d377a7 ctdb-docs: Update documentation of ipreallocated event
This was out of date due to the removal of service_check_reconfigure()
and similar.

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

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Jul 13 17:57:11 CEST 2017 on sn-devel-144
2017-07-13 17:57:11 +02:00
Anoop C S
539714ef19 ctdb-scripts: Fix inline comments in 10.interface
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Jul 11 11:45:04 CEST 2017 on sn-devel-144
2017-07-11 11:45:04 +02:00
Martin Schwenke
22f2068d45 ctdb-scripts: NFS call-out failures should cause event failure
Failures in startup/shutdown/releaseip/takeip are currently
incorrectly ignored.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12837

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-06-13 09:12:19 +02:00
Martin Schwenke
8eafa2c5df ctdb-scripts: Avoid log noise when NFS checks directory is empty
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-20 15:01:13 +01:00
Martin Schwenke
f9368f8e12 ctdb-scripts: Fix regression when cleaning up routing table IDs
Commit 0ca00267cd removed explicit
continuations in strings for awk programs.  In one case this causes a
disconnect between condition and action, where an implicit
continuation does not work.  This results in duplicate lines in the
rt_tables file.

Move the opening brace for the action to make the implicit
continuation work as expected.

An alternative would be to revert the removal of the explicit
continuations and add shellcheck tags.  However, that doesn't mean
that an author of future code will necessarily use explicit
continuations, so the same mistake might still be make in the future.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12516

Reported-by: Barry Evans <bevans@pixitmedia.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-17 02:20:16 +01:00
Martin Schwenke
5e00a6b346 ctdb-scripts: Fix remaining uses of "ctdb gratiousarp"
This changed to "ctdb gratarp" some time ago but the scripts were
never updated.

Fix the documentation for the ctdb tool too.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12512

Reported-by: Ralph Böhme <slow@samba.org>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-17 02:20:16 +01:00
Martin Schwenke
a9870538c9 ctdb-scripts: Drop function ctdb_check_command()
This is only used in 1 place, so just inline the check.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-16 11:57:08 +01:00
Martin Schwenke
c8249dfa0e ctdb-scripts: Inline simple uses of service_start() and service_stop()
This makes the scripts more readable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-16 11:57:08 +01:00
Martin Schwenke
e847ec3ae2 ctdb-scripts: Remove ctdb_service_start() and ctdb_service_stop()
They contain too much unnecessary complexity, some of which was used
to support CTDB_SERVICE_AUTOSTARTSTOP.

Also removed unused functions for service management.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-16 11:57:08 +01:00
Martin Schwenke
e70e77383c ctdb-scripts: Drop configuration variable CTDB_SERVICE_AUTOSTARTSTOP
This has bit-rotted, at least for NFS.  It can be fixed but it is
better to remove it because it adds a lot of unnecessary complexity.

Variable event_name becomes unused so remove it.  Also remove
associated tests.

To continue to manage/unmanage services while CTDB is running:

* Start service by hand and then flag it as managed

* Mark service as unmanaged and shut it down by hand

In some cases CTDB does something fancy - e.g. start Samba under
"nice", so care is needed.  One technique is to disable the
eventscript, mark as managed, run the startup event by hand and then
re-enable the eventscript.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-16 11:57:07 +01:00
Amitay Isaacs
d6f760f78a ctdb-scripts: Add explicit check for service reconfiguration
This will help get rid of implicit ctdb_service_check_reconfigure.

We still need to keep "reconfigure" event in 13.per_ip_routing, so that
the per ip routing can be refreshed if the configuration has changed.
The correct fix for this is to add caching of configuration and checking
of configuration changes in "ipreallocated" event.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-12-16 08:42:32 +01:00
Mathieu Parent
385aef6140 ctdb-scripts: Fix Debian init in samba eventscript
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12371

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
Signed-off-by: Stefan Kania <stefan@kania-online.de>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-11-07 04:02:27 +01:00
Martin Schwenke
72e415be4c ctdb-scripts: Dump stack traces of smbd processes after shutdown
If any processes remain then they may be stuck in D state and this
might tell us why.

Update tests: tweak pidof stub, add support for smbd stack traces and
add some new tests for the shutdown event.

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

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Oct 10 12:54:24 CEST 2016 on sn-devel-144
2016-10-10 12:54:24 +02:00
Martin Schwenke
162857eff1 ctdb-scripts: Add early exit for redundant updateip
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-08-17 23:00:26 +02:00
Martin Schwenke
52b43d73e9 ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list)
SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:27 +02:00
Martin Schwenke
524eac9234 ctdb-scripts: Avoid shellcheck warning SC2094 (read/write same file)
SC2094: Make sure not to read and write the same file in the same pipeline.

The semantics here are unclear, so use a separate flock file in each
case for clarity.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
d7f3b1977f ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n)
SC2039: In POSIX sh, echo flags are not supported.

echo -n is well supported but the changes are simple.

Improve some logic, replace some instances with printf.  Who knew
printf was in POSIX?

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
f43df8f0e9 ctdb-scripts: Avoid shellcheck warning SC2039 (type command)
SC2039: In POSIX sh, 'type' is not supported.

type is commonly supported and is more portable than which(1).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
0ca00267cd ctdb-scripts: Avoid shellcheck warning SC1004 (backslash in quotes)
SC1004: You don't break lines with \ in single quotes, it results in
literal backslash-linefeed.

These don't hurt, since awk can cope with the continuations.  However,
they don't add anything.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
b208ae73d1 ctdb-scripts: Avoid shellcheck warning SC2154 (unassigned variables)
SC2154: VAR is referenced but not assigned.

Change ctdb_setup_service_state_dir(), ctdb_get_pnn() and
ctdb_get_ip_address() to print the value so it can be assigned to a
variable.  The performance gain from avoiding the sub-shells when
calling these functions is close to zero.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
9255d645f3 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting)
SC2046: Quote this to prevent word splitting.
SC2086: Double quote to prevent globbing and word splitting.

Add some quoting where it makes sense.  Use shellcheck directives for
false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
f6c25a455a ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables)
SC2034: VAR appears unused. Verify it or export it.

Drop some variables that are unnecessarily used.  Use shellcheck
directive for false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
13b3c6af64 ctdb-scripts: Avoid shellcheck warning SC2004 ($ in arithmetic)
SC2004: $/${} is unnecessary on arithmetic variables.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
efc9af2634 ctdb-scripts: Avoid shellcheck warnings SC2030, SC2031 (subshell variables)
SC2030: Modification of VAR is local (to subshell caused by (..) group).
SC2031: VAR was modified in a subshell. That change might be lost.

Fix a related, incorrect comment.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
770fe1ff37 ctdb-scripts: Drop use of ctdb_check_counter from vsftpd event script
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
0825eff3e3 ctdb-scripts: Drop use of ctdb_check_counter from reclock event script
This makes the logic more obvious.

Fix the (probably) accidental fall-through to the regular monitor
failure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
92d0d4489e ctdb-scripts: Drop use of ctdb_check_counter from httpd event script
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
fc53256c3f ctdb-scripts: Drop use of service_tcp_ports
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
09a7a7854e ctdb-scripts: Event script indentation and whitespace cleanups
* Re-indent case labels as per new script style

  Other indentation can be tweaked later as code changes, but the
  labels are an obvious bulk change.

* Minor whitespace fixes

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00