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

fix: Remove unecessary code from install script ⚓ #168

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 3 additions & 66 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ function check_bash() {

function get_platform_os() {
local -n _platform_os="$1"
local platform_os_dist=""
local platform_os_version=""

if [[ "$OSTYPE" == "linux"* ]]; then
_platform_os="linux"
Expand All @@ -35,74 +33,13 @@ function get_platform_os() {
local name
name=$(uname -a)
case "$name" in
CYGWIN*) _platform_os="windows" && platform_os_dist="cygwin" ;;
MINGW*) _platform_os="windows" && platform_os_dist="mingw" ;;
*Msys) _platform_os="windows" && platform_os_dist="msys" ;;
CYGWIN*) _platform_os="windows" ;;
MINGW*) _platform_os="windows" ;;
*Msys) _platform_os="windows" ;;
*) die "Platform: '$name' not supported." ;;
esac
fi

if [ "$_platform_os" = "linux" ]; then

if [ "$(lsb_release -si 2>/dev/null)" = "Ubuntu" ] ||
grep -qE 'ID="?ubuntu' "/etc/os-release"; then
platform_os_dist="ubuntu"
platform_os_version=$(grep -m 1 "VERSION_CODENAME=" "/etc/os-release" |
sed -E "s|.*=[\"']?(.*)[\"']?|\1|")
elif grep -qE 'ID="?debian' "/etc/os-release"; then
platform_os_dist="debian"
platform_os_version=$(grep -m 1 "VERSION_CODENAME=" "/etc/os-release" |
sed -E "s|.*=[\"']?(.*)[\"']?|\1|")
elif grep -qE 'ID="?alpine' "/etc/os-release"; then
platform_os_dist="alpine"
platform_os_version=$(grep -m 1 "VERSION_ID=" "/etc/os-release" |
sed -E 's|.*="?([0-9]+\.[0-9]+).*|\1|')
elif grep -qE 'ID="?nixos' "/etc/os-release"; then
platform_os_dist="nixos"
platform_os_version=$(grep -m 1 "VERSION_ID=" "/etc/os-release" |
sed -E 's|.*="?([0-9]+\.[0-9]+).*|\1|')
elif grep -qE 'ID="?rhel' "/etc/os-release"; then
platform_os_dist="redhat"
platform_os_version=$(grep -m 1 "VERSION_ID=" "/etc/os-release" |
sed -E 's|.*="?([0-9]+\.[0-9]+).*|\1|')
elif grep -qE 'ID="?opensuse' "/etc/os-release"; then
platform_os_dist="opensuse"
platform_os_version=$(grep -m 1 "VERSION_ID=" "/etc/os-release" |
sed -E 's|.*="?([0-9]+\.[0-9]+).*|\1|')
else
die "Linux Distro '/etc/os-release' not supported currently:" \
"$(cat /etc/os-release 2>/dev/null)"
fi

# Remove whitespaces
platform_os_dist="${platform_os_dist// /}"
platform_os_version="${platform_os_version// /}"

elif [ "$_platform_os" = "darwin" ]; then

platform_os_dist=$(sw_vers | grep -m 1 'ProductName' | sed -E 's/.*:\s+(.*)/\1/')
platform_os_version=$(sw_vers | grep -m 1 'ProductVersion' | sed -E 's/.*([0-9]+\.[0-9]+\.[0-9]+)/\1/g')
# Remove whitespaces
platform_os_dist="${platform_os_dist// /}"
platform_os_version="${platform_os_version// /}"

elif [ "$_platform_os" = "windows" ]; then
platform_os_version=$(systeminfo | grep -m 1 'OS Version:' | sed -E "s/.*:\s+([0-9]+\.[0-9]+\.[0-9]+).*/\1/")
platform_os_version="${platform_os_version// /}"
else
die "Platform '$_platform_os' not supported currently."
fi

if [ -n "${2:-}" ]; then
local -n _platformOSDist="$2"
_platformOSDist="$platform_os_dist"
fi

if [ -n "${3:-}" ]; then
local -n _platformOSVersion="$3"
_platformOSVersion="$platform_os_version"
fi

return 0
}

Expand Down