From 3e655094e815f764429641a98bbed048fadd7625 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 23 Feb 2013 02:49:14 +0000 Subject: [PATCH] Add `os` and `system` to the list of known release files. * The arch release file will name the distro as "Arch Linux". * Added a function to remove single and double quotes from strings. * When parsing the `os-release` file, unquote the parsed strings. --- bootstrap-salt.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 3aa58c3..76060b4 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -368,6 +368,14 @@ __parse_version_string() { } +#--- FUNCTION ---------------------------------------------------------------- +# NAME: __unquote_string +# DESCRIPTION: Strip single or double quotes from the provided string. +#------------------------------------------------------------------------------- +__unquote_string() { + echo $@ | sed "s/^\([\"']\)\(.*\)\1\$/\2/g" +} + #--- FUNCTION ---------------------------------------------------------------- # NAME: __sort_release_files # DESCRIPTION: Custom sort function. Alphabetical or numerical sort is not @@ -375,8 +383,8 @@ __parse_version_string() { #------------------------------------------------------------------------------- __sort_release_files() { KNOWN_RELEASE_FILES=$(echo "(arch|centos|debian|ubuntu|fedora|redhat|suse|\ - mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb)\ - (-|_)(release|version)" | sed -r 's:[[:space:]]::g') + mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb|system|\ + os)(-|_)(release|version)" | sed -r 's:[[:space:]]::g') primary_release_files="" secondary_release_files="" # Sort know VS un-known files first @@ -449,7 +457,7 @@ __gather_linux_system_info() { [ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource v=$(__parse_version_string "$rv") case $(echo ${n} | tr '[:upper:]' '[:lower:]') in - redhat ) + redhat ) if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then n="CentOS" elif [ ".$(egrep 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then @@ -458,7 +466,7 @@ __gather_linux_system_info() { n="ed at inux" fi ;; - arch ) n="Arch" ;; + arch ) n="Arch Linux" ;; centos ) n="CentOS" ;; debian ) n="Debian" ;; ubuntu ) n="Ubuntu" ;; @@ -480,7 +488,7 @@ __gather_linux_system_info() { done < /etc/${rsource} ;; os ) - n=$(grep '^NAME=' /etc/os-release | sed -e 's/^NAME=\(.*\)$/\1/g') + n=$(__unquote_string $(grep '^NAME=' /etc/os-release | sed -e 's/^NAME=\(.*\)$/\1/g')) ;; * ) n="${n}" ; esac