[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Mon Oct 30 09:20:01 UTC 2023


The branch, master has been updated
       via  9313731e96c ctdb-scripts: Update detect_init_style to use /etc/os-release
      from  952d6c2cf48 smbd: Fix read_symlink_reparse()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9313731e96c29ac2fa41f5ca4f5ccd2a75d17dc9
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Sep 19 17:34:55 2023 +1000

    ctdb-scripts: Update detect_init_style to use /etc/os-release
    
    /etc/os-release is quite universal.  It can be found on most Linux
    distros and on FreeBSD.
    
    Attempt to use /etc/os-release to detect Red Hat, SUSE and Debian
    based distros.  If /etc/os-release exists but distro is unknown then
    $ID is printed as the detected distro, which will probably result in
    sub-optimal behaviour, but when tracing it will at least indicate that
    a new distro needs to be handled.
    
    The only way to handle missing /etc/os-release is to set
    CTDB_INIT_STYLE - see ctdb.sysconfig(5) for details.
    
    The event script unit tests are updated to use /etc/os-release so
    the new logic is exercised.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Mon Oct 30 09:19:11 UTC 2023 on atb-devel-224

-----------------------------------------------------------------------

Summary of changes:
 ctdb/config/functions                          | 50 ++++++++++++++++++++------
 ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local |  4 ++-
 ctdb/tests/UNIT/eventscripts/etc/os-release    |  2 ++
 3 files changed, 45 insertions(+), 11 deletions(-)
 create mode 100644 ctdb/tests/UNIT/eventscripts/etc/os-release


Changeset truncated at 500 lines:

diff --git a/ctdb/config/functions b/ctdb/config/functions
index d8f7f57b84c..a40b276e2b8 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -160,18 +160,48 @@ ctdb_check_args()
 # determine on what type of system (init style) we are running
 detect_init_style()
 {
-	# only do detection if not already set:
-	if [ -n "$CTDB_INIT_STYLE" ]; then
-		return
-	fi
+	_init_style_file="${CTDB_SCRIPT_VARDIR}/init-style"
 
-	if [ -x /sbin/startproc ]; then
-		CTDB_INIT_STYLE="suse"
-	elif [ -x /sbin/start-stop-daemon ]; then
-		CTDB_INIT_STYLE="debian"
-	else
-		CTDB_INIT_STYLE="redhat"
+	if [ ! -f "$_init_style_file" ]; then
+		if [ -n "$CTDB_INIT_STYLE" ]; then
+			echo "$CTDB_INIT_STYLE" >"$_init_style_file"
+			return
+		fi
+
+		# 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"
 	fi
+
+	read -r CTDB_INIT_STYLE <"$_init_style_file"
 }
 
 ######################################################
diff --git a/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local b/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local
index aa9b8b22fec..777aeaff8b3 100755
--- a/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local
+++ b/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local
@@ -51,4 +51,6 @@ background_with_logging ()
     "$@" 2>&1 </dev/null | sed -e 's@^@\&@'
 }
 
-CTDB_INIT_STYLE="${EVENTSCRIPT_TESTS_INIT_STYLE:-redhat}"
+if [ -n "$EVENTSCRIPT_TESTS_INIT_STYLE" ]; then
+	CTDB_INIT_STYLE="$EVENTSCRIPT_TESTS_INIT_STYLE"
+fi
diff --git a/ctdb/tests/UNIT/eventscripts/etc/os-release b/ctdb/tests/UNIT/eventscripts/etc/os-release
new file mode 100644
index 00000000000..f0057cc43ae
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/etc/os-release
@@ -0,0 +1,2 @@
+ID="rocky"
+ID_LIKE="rhel centos fedora"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list