Add package manager detection (partially)

This commit is contained in:
askiiart 2023-08-23 21:25:12 -05:00
parent d34792d34d
commit 36a1d3395d
No known key found for this signature in database
GPG key ID: 85505F3A2264FA01
2 changed files with 45 additions and 16 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Exit if there's an error
set -e
# Modify constants as needed
@ -9,6 +9,24 @@ EMAIL="dev@askiiart.net"
# Note: This waits until enter is pressed
# read -p "Press Enter to continue" < /dev/tty
command_exists() { type "$1" &> /dev/null; }
if command_exists "apt-get"; then
PM="apt-get"
elif command_exists "yum"; then
PM="yum"
elif command_exists "pacman"; then
PM="pacman"
elif command_exists "zypp"; then
PM="zypp"
elif command_exists "emerge"; then
PM="emerge"
elif command_exists "apk"; then
PM="apk"
else
echo "Unsupported: unknown package manager"
fi
declare -A osInfo;
osInfo[/etc/redhat-release]=yum
osInfo[/etc/arch-release]=pacman
@ -24,6 +42,7 @@ do
fi
done
sudo ${PACKAGE_MANAGER} install pass git -y
# Check if GCM is installed

View file

@ -1,21 +1,31 @@
#!/bin/bash
#!/usr/bin/env bash
# Exit if there's an error
set -e
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 f in ${!osInfo[@]}
do
if [[ -f $f ]];then
PACKAGE_MANAGER=${osInfo[$f]}
fi
done
if [ $(whoami) != "root" ]; then
$SUDO = "sudo"
exit 1
fi
exit 0
command_exists() { type "$1" &> /dev/null; }
sudo ${PACKAGE_MANAGER} install zsh -y
if command_exists "apt-get"; then
$SUDO apt-get install zsh -y
elif command_exists "yum"; then
$SUDO apt-get install zsh -y
elif command_exists "pacman"; then
$SUDO pacman -S zsh --noconfirm --needed
elif command_exists "zypper"; then
$SUDO zypper install zsh -y
elif command_exists "emerge"; then
$SUDO emerge --ask app-shells/zsh
$SUDO emerge --ask app-shells/zsh-completions
$SUDO emerge --ask app-shells/gentoo-zsh-completions
elif command_exists "apk"; then
$SUDO apk add zsh -y;
else
>&2 echo "Unsupported: unknown package manager"
exit 1
fi
cp -r zsh-files/* ~/