diff options
Diffstat (limited to '.github/os_detect.sh')
-rw-r--r-- | .github/os_detect.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/.github/os_detect.sh b/.github/os_detect.sh new file mode 100644 index 00000000..ee9c145d --- /dev/null +++ b/.github/os_detect.sh | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/bin/sh -e | ||
2 | # workaround for really bare-bones Archlinux containers: | ||
3 | if [ -x "$(command -v pacman)" ]; then | ||
4 | pacman --noconfirm -Sy | ||
5 | pacman --noconfirm -S grep gawk sed | ||
6 | fi | ||
7 | |||
8 | os_release_file= | ||
9 | if [ -s "/etc/os-release" ]; then | ||
10 | os_release_file="/etc/os-release" | ||
11 | elif [ -s "/usr/lib/os-release" ]; then | ||
12 | os_release_file="/usr/lib/os-release" | ||
13 | else | ||
14 | echo >&2 "Cannot find an os-release file ..." | ||
15 | return 1 | ||
16 | fi | ||
17 | export distro_id=$(grep '^ID=' $os_release_file|awk -F = '{print $2}'|sed 's/\"//g') | ||
18 | export platform_id=$(grep '^PLATFORM_ID=' /etc/os-release|awk -F = '{print $2}'|sed 's/\"//g'| cut -d":" -f2) | ||