ctdb-scripts: Factor out function ctdb_setup_state_dir()
authorMartin Schwenke <martin@meltin.net>
Tue, 6 Feb 2018 02:49:46 +0000 (13:49 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:24 +0000 (07:08 +0100)
commitfac6d23d2758428cefdabb8bb07bd83cd76deace
tree46ac5b05513155b9a57368fe4da9c908aec1a65d
parent208996134632cfa99654238a089849fc19ddca52
ctdb-scripts: Factor out function ctdb_setup_state_dir()

This allows state directories for scripts other than services.
ctdb_setup_state_dir() takes 2 mandatory arguments.

Unlike ctdb_setup_service_state_dir(), this does not print the
directory name but sets a global variable.  The intention is to go
back to a more sensible style of usage.

This will require a shellcheck directive before the first use, such
as:

  # Set by ctdb_setup_state_dir
  # shellcheck disable=SC2154
  foo="${script_state_dir}/bar"

An alternative would be something like the following, which tricks
shellcheck into believing the variable is set:

  ctdb_setup_state_dir "service" "foo"
  # Shellcheck
  script_state_dir="$script_state_dir"

However, this is more cryptic.

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