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

27
scripts/util/color.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
BLACK="\033[30m"
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
BLUE="\033[34m"
PINK="\033[35m"
CYAN="\033[36m"
WHITE="\033[37m"
RESET="\033[0;39m"
print_info() {
echo -e "$RESET"["$BLUE"i"$RESET"] $@
}
print_warn () {
echo -e "$RESET"["$YELLOW"!"$RESET"] $@
}
print_error () {
echo -e "$RESET"["$RED"x"$RESET"] $@
}
print_info Hello
print_warn Hello
print_error Hello

23
scripts/util/pkg-mgr.sh Executable file
View File

@ -0,0 +1,23 @@
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 "$@"
elif [ "$PACKAGE_MANAGER" == "pacman" ]; then pacman -S --noconfirm "$@"
elif [ "$PACKAGE_MANAGER" == "emerge" ]; then emerge "$@"
elif [ "$PACKAGE_MANAGER" == "zypp" ]; then zypper install "$@"
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then apt-get install -y "$@"
elif [ "$PACKAGE_MANAGER" == "apk" ]; then apk add "$@"; fi
}