mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-24 20:10:20 +01:00
49 lines
1.4 KiB
Text
49 lines
1.4 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
declare -A os_family=( [RedHat]=RedHat [CentOS]=RedHat [Fedora]=RedHat
|
||
|
[AlmaLinux]=RedHat [Rocky]=RedHat [OracleLinux]=RedHat )
|
||
|
|
||
|
for file in vars/*.yml; do
|
||
|
if [ "$file" = vars/main.yml ]; then
|
||
|
continue
|
||
|
fi
|
||
|
# get platform and optional version
|
||
|
if [[ "$file" =~ vars/([^_]+)_([0-9]+).yml$ ]]; then
|
||
|
platform="${BASH_REMATCH[1]}"
|
||
|
version="${BASH_REMATCH[2]}"
|
||
|
packages_file=".ostree/packages-runtime-${platform}-${version}.txt"
|
||
|
elif [[ "$file" =~ vars/([^_.]+).yml$ ]]; then
|
||
|
platform="${BASH_REMATCH[1]}"
|
||
|
packages_file=".ostree/packages-runtime-${platform}.txt"
|
||
|
else
|
||
|
echo ERROR: cannot parse "$file"
|
||
|
exit 1
|
||
|
fi
|
||
|
# only os_family == RedHat is supported
|
||
|
if [ "${os_family[$platform]:-}" = RedHat ]; then
|
||
|
: # proceed - fall through
|
||
|
else
|
||
|
echo platform "$platform" not supported for ostree
|
||
|
continue
|
||
|
fi
|
||
|
# parse packages from file
|
||
|
printit=0
|
||
|
while read -r item pkg; do
|
||
|
if [[ "$item" =~ ^__sshd_packages: ]]; then
|
||
|
printit=1
|
||
|
elif [ "$printit" = 1 ]; then
|
||
|
if [ "$item" = "-" ] && [ -n "$pkg" ]; then
|
||
|
echo "$pkg"
|
||
|
else
|
||
|
break
|
||
|
fi
|
||
|
fi
|
||
|
done < "$file" | sort > "$packages_file"
|
||
|
# remove empty files
|
||
|
if [ ! -s "$packages_file" ]; then
|
||
|
rm -f "$packages_file"
|
||
|
fi
|
||
|
done
|