Improve setup and update scripts pt.2
This commit is contained in:
27
scripts/util/color.sh
Executable file
27
scripts/util/color.sh
Executable 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
23
scripts/util/pkg-mgr.sh
Executable 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
|
||||
}
|
Reference in New Issue
Block a user