Improve setup and update scripts pt.2

This commit is contained in:
2023-06-20 23:12:12 -05:00
parent 1a7c8c160d
commit f9d7c98916
10 changed files with 105 additions and 96 deletions

View File

@ -18,28 +18,16 @@ alias md='mkdir -p'
alias rd='rm -rf'
alias q='exit'
alias c='clear'
alias journal='journalctl -xe'
alias journal-err='journalctl -p 3 -b'
alias fstab='sudo vim /etc/fstab'
alias fstab='_ vim /etc/fstab'
alias rcron='sudo crontab -e'
alias cron='crontab -e'
alias upd-arch='paru -S archlinux-keyring && paru'
alias upd-ubt='sudo apt update -y && sudo apt upgrade -y'
if [[ "$OS" == "Arch Linux" ]]; then
alias upd='upd-arch'
elif [[ $OS == "Ubuntu" ]]; then
alias upd='upd-ubt'
else
alias upd='echo Failed to detect distribution. The script needs to be able to determine the distribution to know which package manager to use'
fi
alias reload='source ~/.zshrc'
alias aliases='cat $ALIASES'

View File

@ -1,29 +0,0 @@
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi

View File

@ -1,22 +0,0 @@
declare -A osInfo;
osInfo[/etc/redhat-release]=yum
osInfo[/etc/arch-release]=pacman
osInfo[/etc/gentoo-release]=emerge
osInfo[/etc/SuSE-release]=zypp
osInfo[/etc/debian_version]=apt-get
osInfo[/etc/alpine-release]=apk
for key val in "${(@kv)osInfo}"; do
if [[ -f $key ]];then
PACKAGE_MANAGER=$val
fi
done
install_package() {
if [ "$PACKAGE_MANAGER" == "yum" ]; then yum install -y $1
elif [ "$PACKAGE_MANAGER" == "pacman" ]; then pacman -S --noconfirm $1
elif [ "$PACKAGE_MANAGER" == "emerge" ]; then emerge $1
elif [ "$PACKAGE_MANAGER" == "zypp" ]; then zypper install $1
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then apt-get install -y $1
elif [ "$PACKAGE_MANAGER" == "apk" ]; then apk add $1; fi
}