Merge pull request #70 from mlocati/add-getDistroVersion

Add getDistroVersion function
pull/67/head
Michele Locati 2019-12-20 14:20:48 +01:00 committed by GitHub
commit 544fee9d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 11 deletions

View File

@ -26,19 +26,28 @@ getDistro () {
getDistro_os_id='' getDistro_os_id=''
if test -r /etc/os-release; then if test -r /etc/os-release; then
getDistro_os_id="$(cat /etc/os-release | grep -E ^ID= | cut -d = -f 2)" getDistro_os_id="$(cat /etc/os-release | grep -E ^ID= | cut -d = -f 2)"
case "$getDistro_os_id" in
alpine|debian)
;;
*)
getDistro_os_id=''
;;
esac
fi fi
if test -n "$getDistro_os_id"; then
printf '%s' "$getDistro_os_id" printf '%s' "$getDistro_os_id"
else }
printf '%s' 'debian'
# Get the distribution name and the version
#
# Example output:
# alpine@3.10
# debian@9
getDistroVersion () {
getDistroVersion_distro="$(getDistro)"
if test -z "$getDistroVersion_distro"; then
return
fi fi
getDistroVersion_versionID=''
if test -r /etc/os-release; then
getDistroVersion_versionID="$(cat /etc/os-release | grep -E ^VERSION_ID= | cut -d = -f 2 | cut -d '"' -f 2 | cut -d . -f 1,2)"
fi
if test -z "$getDistroVersion_distro"; then
return
fi
printf '%s@%s' "$getDistroVersion_distro" "$getDistroVersion_versionID"
} }
# Get the PHP Major-Minor version as an integer value, in format MMmm (example: 506 for PHP 5.6.15) # Get the PHP Major-Minor version as an integer value, in format MMmm (example: 506 for PHP 5.6.15)