Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
F #-: Support ID_LIKE in /etc/os-release if it exists
Browse files Browse the repository at this point in the history
Useful for unsupported distributions based off supported distributions

Signed-off-by: Cody Robertson <[email protected]>
  • Loading branch information
codyro authored and rsmontero committed Apr 26, 2023
1 parent 0af6e4a commit 610badf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
55 changes: 29 additions & 26 deletions src/etc/one-context.d/loc-10-network
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,35 @@ if [ -z "${action}" ] ; then
fi

if [ -z "${NETCFG_TYPE}" ] ; then
case "${os_id}" in
alpine)
NETCFG_TYPE='interfaces'
;;
altlinux)
NETCFG_TYPE='networkd nm'
;;
debian|devuan|ubuntu)
NETCFG_TYPE='interfaces netplan nm networkd'
;;
fedora|centos|rhel|almalinux|ol|rocky)
NETCFG_TYPE='scripts nm networkd'
;;
opensuse*|sles|sled)
NETCFG_TYPE='scripts'
;;
amzn)
NETCFG_TYPE='scripts'
;;
freebsd)
NETCFG_TYPE='bsd'
;;
*)
NETCFG_TYPE='none'
;;
esac
for id in ${os_id}; do
case "${id}" in
alpine)
NETCFG_TYPE='interfaces'
;;
altlinux)
NETCFG_TYPE='networkd nm'
;;
debian|devuan|ubuntu)
NETCFG_TYPE='interfaces netplan nm networkd'
;;
fedora|centos|rhel|almalinux|ol|rocky)
NETCFG_TYPE='scripts nm networkd'
;;
opensuse*|sles|sled)
NETCFG_TYPE='scripts'
;;
amzn)
NETCFG_TYPE='scripts'
;;
freebsd)
NETCFG_TYPE='bsd'
;;
*)
NETCFG_TYPE='none'
;;
esac
break
done
else
# trim and lowercase
NETCFG_TYPE=$(echo "$NETCFG_TYPE" | \
Expand Down
3 changes: 2 additions & 1 deletion src/etc/one-context.d/loc-10-network.d/functions
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ detect_os()
(
if [ -f /etc/os-release ] ; then
ID=
ID_LIKE=
# shellcheck disable=SC1091
. /etc/os-release
echo "$ID" | tr '[:upper:]' '[:lower:]'
echo "$ID $ID_LIKE" | tr '[:upper:]' '[:lower:]'

# check for legacy RHEL/CentOS 6
elif [ -f /etc/centos-release ]; then
Expand Down

0 comments on commit 610badf

Please sign in to comment.