Better installer and colors for most scripts.

This commit is contained in:
2024-01-07 23:00:07 +00:00
parent ba5810c091
commit 566a8fcbbc
2 changed files with 128 additions and 57 deletions

View File

@@ -1,6 +1,8 @@
#! /bin/bash
# Cross-distro package manager wrapper
source ~/dotfiles/scripts/color.sh
d() {
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo 1
@@ -18,7 +20,7 @@ m() {
elif [ $d == 1 ]; then
~/dotfiles/scripts/debian-maintenance.sh
else
echo "ERROR - Distro not supported."
echo -e "${RED}[E] Distro not supported.${ENDCOLOR}"
return 1
fi
}
@@ -55,55 +57,56 @@ p() {
# If no parameter
if [ -z $1 ] || [ $1 == "u" ]; then
echo "[+] Updating distro packages..."
echo -e "${GREEN}"[+] Updating distro packages..."${ENDCOLOR}"
$update
if $flatpak; then
echo
echo "[+] Updating flatpaks..."
echo -e "${GREEN}"[+] Updating flatpaks..."${ENDCOLOR}"
flatpak upgrade
fi
echo "[I] done."
echo -e "${GREEN}"[i] done."${ENDCOLOR}"
return 0
elif [ $1 == "i" ]; then # If first parameter is i (install)
echo "[+] Searching for $2 on the distro repos..."
echo -e "${GREEN}"[+] Searching for $2 on the distro repos..."${ENDCOLOR}"
$install $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was installed."
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}"
return 0
else
if $flatpak; then
echo
echo "[E] $2 not found."
echo "[+] Searching for $2 as a flatpak..."
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}"
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}"
echo
flatpak install $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was installed."
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}"
return 0
fi
fi
echo "[E] $2 not found or already installed."
echo -e "${RED}"[E] $2 not found or already installed."${ENDCOLOR}"
return 2
fi
elif [ $1 == "r" ]; then # If first parameter is r (remove)
echo "[+] Removing $2..."
echo -e "${YELLOW}"[+] Removing $2..."${ENDCOLOR}"
$remove $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was removed."
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}"
return 0
else
if $flatpak; then
echo
echo "[E] $2 not found."
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}"
echo "[+] Searching for $2 as a flatpak..."
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}"
echo
flatpak remove $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was removed."
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}"
return 0
fi
fi
echo "[E] $2 not found."
echo -e "${RED}"[E] $2 not found."${ENDCOLOR}"
return 2
fi
elif [ $1 == "c" ]; then # If first parameter is c (check)
@@ -141,7 +144,7 @@ p() {
echo 2
fi
else
echo "[I] Usage:"
echo -e "${YELLOW}"[i] Usage:"${ENDCOLOR}"
echo "p (u) -> update os"
echo "p i package -> install package"
echo "p r package -> remove package"
@@ -149,7 +152,7 @@ p() {
echo "d -> returns 1 -> Debian; 2 -> Arch; 0 -> Error"
echo "m -> maintenance script"
echo
echo "[I] Order of operations:"
echo -e "${YELLOW}"[i] Order of operations:"${ENDCOLOR}"
echo "1 - Check distro repos"
echo "2 - Check AUR if on Arch"
echo "3 - Check flatpaks (only if flatpak support is enabled)"