load_system_config "ctdb"
-detect_init_style
-export CTDB_INIT_STYLE
-
ctdbd="${CTDBD:-/usr/sbin/ctdbd}"
ctdb="${CTDB:-/usr/bin/ctdb}"
pidfile="/var/run/ctdb/ctdbd.pid"
{
printf "Starting ctdbd service: "
- case "$CTDB_INIT_STYLE" in
+ case "$CTDB_PLATFORM_STYLE" in
suse)
startproc "$ctdbd"
rc_status -v
{
printf "Shutting down ctdbd service: "
- case "$CTDB_INIT_STYLE" in
+ case "$CTDB_PLATFORM_STYLE" in
suse)
"$ctdb" "shutdown"
rc_status -v
check_status()
{
- case "$CTDB_INIT_STYLE" in
+ case "$CTDB_PLATFORM_STYLE" in
suse)
checkproc -p "$pidfile" "$ctdbd"
rc_status -v
ulimit -c unlimited
# Useful if default detection doesn't work
-# CTDB_INIT_STYLE=debian
+# CTDB_PLATFORM_STYLE=debian
. "${CTDB_BASE}/functions"
-detect_init_style
-
-case $CTDB_INIT_STYLE in
+case "$CTDB_PLATFORM_STYLE" in
redhat)
service_name="clamd"
;;
. "${CTDB_BASE}/functions"
-detect_init_style
-
-case $CTDB_INIT_STYLE in
+case "$CTDB_PLATFORM_STYLE" in
redhat)
service_name="httpd"
;;
. "${CTDB_BASE}/functions"
-detect_init_style
-
-case $CTDB_INIT_STYLE in
+case "$CTDB_PLATFORM_STYLE" in
*)
# distributions don't have this yet,
# but assume samba-dcerpcd as service name
. "${CTDB_BASE}/functions"
-detect_init_style
-
-case $CTDB_INIT_STYLE in
+case $CTDB_PLATFORM_STYLE in
suse)
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
;;
. "${CTDB_BASE}/functions"
-detect_init_style
-
-case $CTDB_INIT_STYLE in
+case "$CTDB_PLATFORM_STYLE" in
suse)
CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
;;
}
##############################################################
-# determine on what type of system (init style) we are running
-detect_init_style()
+# determine on what type of system we are running
+detect_platform_style()
{
- _init_style_file="${CTDB_SCRIPT_VARDIR}/init-style"
+ CTDB_PLATFORM_STYLE=""
- if [ ! -f "$_init_style_file" ]; then
- if [ -n "$CTDB_INIT_STYLE" ]; then
- echo "$CTDB_INIT_STYLE" >"$_init_style_file"
- return
- fi
+ _os_release="${CTDB_SYS_ETCDIR}/os-release"
+ if [ -f "$_os_release" ]; then
+ # Limit the variables that might be set
+ eval "$(grep '^ID=\|^ID_LIKE=' "$_os_release")"
- # Subshell to contain variables in os-release file
- (
- _os_release="${CTDB_SYS_ETCDIR}/os-release"
- if [ -f "$_os_release" ]; then
- . "$_os_release"
- case "$ID" in
- centos | fedora | rhel)
- echo "redhat"
- ;;
- debian | ubuntu)
- echo "debian"
- ;;
- sles | suse)
- echo "suse"
- ;;
- *)
- case "$ID_LIKE" in
- *centos* | *rhel*)
- echo "redhat"
- ;;
- *)
- echo "$ID"
- ;;
- esac
- ;;
- esac
- else
- echo "WARNING: unknown distribution ${ID}" >&2
- echo "unknown"
- fi
- ) >"$_init_style_file"
+ case "$ID" in
+ centos | fedora | rhel)
+ CTDB_PLATFORM_STYLE="redhat"
+ ;;
+ debian | ubuntu)
+ CTDB_PLATFORM_STYLE="debian"
+ ;;
+ sles | suse)
+ CTDB_PLATFORM_STYLE="suse"
+ ;;
+ *)
+ case "$ID_LIKE" in
+ *centos* | *rhel*)
+ CTDB_PLATFORM_STYLE="redhat"
+ ;;
+ *)
+ CTDB_PLATFORM_STYLE="$ID"
+ ;;
+ esac
+ ;;
+ esac
+
+ unset -v ID ID_LIKE 2>/dev/null
+ fi
+
+ if [ -z "$CTDB_PLATFORM_STYLE" ]; then
+ echo "WARNING: unknown platform" >&2
+ CTDB_PLATFORM_STYLE="unknown"
fi
+}
+
+detect_platform_style
- read -r CTDB_INIT_STYLE <"$_init_style_file"
+detect_init_style()
+{
+ # CTDB_INIT_STYLE may be used by 3rd party scripts
+ # shellcheck disable=SC2034
+ CTDB_INIT_STYLE="$CTDB_PLATFORM_STYLE"
}
######################################################
<variablelist>
<varlistentry>
- <term>CTDB_INIT_STYLE=debian|redhat|suse</term>
+ <term>CTDB_PLATFORM_STYLE=debian|redhat|suse|freebsd</term>
<listitem>
<para>
- This is the init style used by the Linux distribution (or
+ This characterises the Linux distribution (or
other operating system) being used. This is usually
determined dynamically by checking the system. This
- variable is used by the initscript to determine which init
- system primitives to use. It is also used by some
- eventscripts to choose the name of initscripts for certain
- services, since these can vary between distributions.
+ variable is used by:
</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ The initscript to determine which init system
+ primitives to use.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Some event scripts to determine services names, since
+ these can vary between distributions.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Some shell functions to determine which options to use
+ for certain commands.
+ </para>
+ </listitem>
+ </itemizedlist>
<para>
If using CTDB's event scripts are unable to determine an
appropriate default then this option can also be placed in
<manvolnum>5</manvolnum></citerefentry> file.
</para>
<para>
- Default: NONE. Guessed, based on features of
- distribution.
+ Default: Based on contents of
+ <filename>/etc/os-release</filename>.
</para>
</listitem>
</varlistentry>
setup
-export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
+export EVENTSCRIPT_TESTS_PLATFORM_STYLE="debian"
ok <<EOF
Stopping nmbd: OK
setup
-export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
+export EVENTSCRIPT_TESTS_PLATFORM_STYLE="debian"
ok <<EOF
Starting nmbd: OK
setup
-export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
+export EVENTSCRIPT_TESTS_PLATFORM_STYLE="debian"
ok <<EOF
Stopping smbd: OK
setup
-export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
+export EVENTSCRIPT_TESTS_PLATFORM_STYLE="debian"
ok <<EOF
Starting smbd: OK
"$@" 2>&1 </dev/null | sed -e 's@^@\&@'
}
-if [ -n "$EVENTSCRIPT_TESTS_INIT_STYLE" ]; then
- CTDB_INIT_STYLE="$EVENTSCRIPT_TESTS_INIT_STYLE"
+if [ -n "$EVENTSCRIPT_TESTS_PLATFORM_STYLE" ]; then
+ CTDB_PLATFORM_STYLE="$EVENTSCRIPT_TESTS_PLATFORM_STYLE"
fi