Add package manager detection (partially)
This commit is contained in:
parent
d34792d34d
commit
36a1d3395d
2 changed files with 45 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# Exit if there's an error
|
# Exit if there's an error
|
||||||
set -e
|
set -e
|
||||||
# Modify constants as needed
|
# Modify constants as needed
|
||||||
|
@ -9,6 +9,24 @@ EMAIL="dev@askiiart.net"
|
||||||
# Note: This waits until enter is pressed
|
# Note: This waits until enter is pressed
|
||||||
# read -p "Press Enter to continue" < /dev/tty
|
# 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;
|
declare -A osInfo;
|
||||||
osInfo[/etc/redhat-release]=yum
|
osInfo[/etc/redhat-release]=yum
|
||||||
osInfo[/etc/arch-release]=pacman
|
osInfo[/etc/arch-release]=pacman
|
||||||
|
@ -24,6 +42,7 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
sudo ${PACKAGE_MANAGER} install pass git -y
|
sudo ${PACKAGE_MANAGER} install pass git -y
|
||||||
|
|
||||||
# Check if GCM is installed
|
# Check if GCM is installed
|
||||||
|
|
|
@ -1,21 +1,31 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# Exit if there's an error
|
# Exit if there's an error
|
||||||
set -e
|
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[@]}
|
if [ $(whoami) != "root" ]; then
|
||||||
do
|
$SUDO = "sudo"
|
||||||
if [[ -f $f ]];then
|
exit 1
|
||||||
PACKAGE_MANAGER=${osInfo[$f]}
|
fi
|
||||||
fi
|
exit 0
|
||||||
done
|
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/* ~/
|
cp -r zsh-files/* ~/
|
Loading…
Reference in a new issue