mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
fix(install-script): Better OS detection, fix non-existent method call
This commit is contained in:
@@ -1,41 +1,26 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
OS_PACKAGE_FILE=package-list-os
|
OS_PACKAGE_FILE=package-list-os
|
||||||
|
OS_INSTALL_COMMAND=""
|
||||||
|
OS_PKG_CHECK_COMMAND=""
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
OS_INSTALL_COMMAND=""
|
if [ -f /etc/debian_version ] || [ -f /etc/ubuntu_version ]; then
|
||||||
OS_PKG_CHECK_COMMAND=""
|
|
||||||
|
|
||||||
# First try to get OS info from os-release
|
|
||||||
if [ -f /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
OS_TYPE="$ID"
|
|
||||||
else
|
|
||||||
# Fallback to uname
|
|
||||||
OS_TYPE="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$OS_TYPE" in
|
|
||||||
"debian" | "ubuntu")
|
|
||||||
OS_INSTALL_COMMAND="apt-get install -y"
|
OS_INSTALL_COMMAND="apt-get install -y"
|
||||||
OS_PKG_CHECK_COMMAND="apt-cache show"
|
OS_PKG_CHECK_COMMAND="apt-cache show"
|
||||||
apt_setup
|
apt_setup
|
||||||
;;
|
elif [ -f /etc/rocky-release ] || [ -f /etc/almalinux-release ] || [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then # Rocky, Almalinux,
|
||||||
"fedora" | "rhel" | "centos")
|
|
||||||
OS_INSTALL_COMMAND="dnf install -y --allowerasing --skip-broken"
|
OS_INSTALL_COMMAND="dnf install -y --allowerasing --skip-broken"
|
||||||
OS_PKG_CHECK_COMMAND="dnf list available"
|
OS_PKG_CHECK_COMMAND="dnf list available"
|
||||||
dnf_setup
|
dnf_setup
|
||||||
;;
|
elif [ -f /etc/freebsd-update.conf ]; then # FreeBSD
|
||||||
"freebsd" | "ghostbsd")
|
|
||||||
OS_INSTALL_COMMAND="pkg install -y"
|
OS_INSTALL_COMMAND="pkg install -y"
|
||||||
OS_PKG_CHECK_COMMAND="pkg search"
|
OS_PKG_CHECK_COMMAND="pkg search"
|
||||||
freebsd_setup
|
freebsd_setup
|
||||||
;;
|
else
|
||||||
*)
|
echo "Unsupported operating system"
|
||||||
log "Unsupported operating system: $OS_TYPE"
|
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
freebsd_setup() {
|
freebsd_setup() {
|
||||||
|
|||||||
Reference in New Issue
Block a user