Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9240: Repository addition in rudder-setup fails when lsb_release is unavailable on Debian like OSes #222

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/rudder-setup/add-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ add_repo() {
# Debian / Ubuntu like
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 474A19E8
cat > /etc/apt/sources.list.d/rudder.list << EOF
deb ${URL_BASE} $(lsb_release -cs) main
deb ${URL_BASE} ${OS_CODENAME} main
EOF
apt-get update
return 0
Expand Down
21 changes: 14 additions & 7 deletions scripts/rudder-setup/detect-os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ detect_os() {
PM_INSTALL="echo Your package manager is not yet supported"
PM_UPGRADE="echo Your package manager is not yet supported"
PM_LOCAL_INSTALL="echo Your package manager is not yet supported for local install"

# detect package manager
########################
# TODO macports, homebrew, portage
Expand Down Expand Up @@ -56,10 +56,16 @@ detect_os() {
PM_LOCAL_INSTALL="eval yes | pkgadd -d"
fi

# install lsb_release if required
#################################

if [ -e /etc/debian_version ]; then
${PM_INSTALL} lsb-release
fi

# detect os and version
#######################

if [ "$(uname -s)" = "AIX" ]; then
OS_NAME="AIX"
# Format: Major.Minor (Ex: 5.3)
Expand All @@ -72,11 +78,12 @@ detect_os() {
elif exists lsb_release; then
OS_NAME=`lsb_release -is`
OS_VERSION=`lsb_release -rs`
OS_CODENAME=`lsb_release -cs`

# manual detection adapted from FusionInventory lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm
# manual detection adapted from FusionInventory lib/FusionInventory/Agent/Task/Inventory/Linux/Distro/NonLSB.pm
elif release_file 'VMWare' '/etc/vmware-release' '.*\([0-9.]\+\).*'; then true
elif release_file 'ArchLinux' '/etc/arch-release' '\(.*\)'; then true
elif release_file 'Debian' '/etc/debian_version' '\(.*\)'; then
elif release_file 'Debian' '/etc/debian_version' '\(.*\)'; then
if [ "${OS_VERSION}" = "jessie/sid" ]; then OS_VERSION=7; fi
elif release_file 'Fedora' '/etc/fedora-release' '.*release \([0-9.]\+\)'; then true
elif release_file 'Gentoo' '/etc/gentoo-release' '\(.*\)'; then true
Expand All @@ -88,7 +95,7 @@ detect_os() {
elif release_file 'RedHat' '/etc/redhat-release' '.*release \([0-9.]\+\).*'; then true
elif release_file 'Slackware' '/etc/slackware-version' '.*Slackware \(.*\).*'; then true
elif release_file 'Trustix' '/etc/trustix-release' '.*release \([0-9.]\+\).*'; then true
elif release_file 'SuSE' '/etc/SuSE-release' 'VERSION *= *\([0-9.]\+\).*'; then
elif release_file 'SuSE' '/etc/SuSE-release' 'VERSION *= *\([0-9.]\+\).*'; then
OS_VERSION="${OS_VERSION}-`sed -n '/PATCHLEVEL/s/PATCHLEVEL *= *\([0-9.]\+\).*/\1/p' /etc/SuSE-release`"
elif release_file 'Amazon' '/etc/system-release-cpe' '[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*'; then true
fi
Expand All @@ -101,12 +108,12 @@ detect_os() {
RedHat) OS_COMPATIBLE="RHEL" ;;
Oracle) OS_COMPATIBLE="RHEL" ;;
CentOS) OS_COMPATIBLE="RHEL" ;;
Amazon) OS_COMPATIBLE="RHEL"
Amazon) OS_COMPATIBLE="RHEL"
OS_COMPATIBLE_VERSION=6;;
SuSE) OS_COMPATIBLE="SLES" ;;
"SUSE LINUX") OS_COMPATIBLE="SLES" ;;
esac

export OS_NAME OS_COMPATIBLE OS_VERSION OS_COMPATIBLE_VERSION PM PM_INSTALL
}