mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-02-17 23:30:47 +01:00
Write boilerplate shell for managing Arch packages
This commit is contained in:
parent
7d0eaabe49
commit
24fe1beffd
115
installs/arch.sh
115
installs/arch.sh
@ -1,48 +1,99 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# List of packages to be installed on Arch-based systems
|
###############################################################
|
||||||
# Desktop apps installed via Flatpak, PKGBUILDs via Pacman
|
# Installs listed packages on Arch-based systems via Pacman #
|
||||||
# Apps are sorted by category, and arranged alphabetically
|
# Doesn't include desktop apps, that're managed via Flatpak #
|
||||||
# Be sure to delete / comment out anything you do not need
|
# Apps are sorted by category, and arranged alphabetically #
|
||||||
|
# Be sure to delete / comment out anything you do not need #
|
||||||
set -e
|
# For more info, see: https://wiki.archlinux.org/title/Pacman #
|
||||||
|
###############################################################
|
||||||
|
# MIT Licensed (C) Alicia Sykes 2022 <https://aliciasykes.com>#
|
||||||
|
###############################################################
|
||||||
|
|
||||||
# Apps to be installed via Pacman
|
# Apps to be installed via Pacman
|
||||||
pacman_apps=(
|
pacman_apps=(
|
||||||
# Apps
|
|
||||||
|
|
||||||
|
|
||||||
# Development
|
|
||||||
|
|
||||||
|
|
||||||
# Utils
|
|
||||||
|
|
||||||
# Security Utils
|
|
||||||
|
|
||||||
|
|
||||||
# Netowking
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Colors
|
||||||
CYAN_B='\033[1;96m'
|
CYAN_B='\033[1;96m'
|
||||||
YELLOW_B='\033[1;93m'
|
YELLOW='\033[0;93m'
|
||||||
RED_B='\033[1;31m'
|
|
||||||
GREEN_B='\033[1;32m'
|
|
||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
PURPLE='\033[0;35m'
|
||||||
|
LIGHT='\x1b[2m'
|
||||||
|
|
||||||
echo "${CYAN_B}Installing Arch Packages...${RESET}"
|
PROMPT_TIMEOUT=15 # When user is prompted for input, skip after x seconds
|
||||||
|
|
||||||
# Pacman
|
# Print intro message
|
||||||
if hash pacman 2> /dev/null; then
|
echo -e "${PURPLE}Starting Arch app install / update script"
|
||||||
for app in ${pacman_apps[@]}; do
|
echo -e "${LIGHT}The following script is for Arch / Arch-based headless systems, and will"
|
||||||
# If pacman -Qk ${app}
|
echo -e "update database, upgrade packages, clear cache then install all listed CLI apps."
|
||||||
# And If: flatpak list --columns=ref | grep 'ch.protonmail.protonmail-bridge'
|
echo -e "${YELLOW}Before proceeding, ensure your happy with all the packages listed in \e[4m${0##*/}"
|
||||||
pacman -S ${app}
|
echo -e "${RESET}"
|
||||||
done
|
|
||||||
else
|
# Check if running as root, and prompt for password if not
|
||||||
echo "${YELLOW_B}Pacman not present, skipping${RESET}"
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo -e "${PURPLE}Elevated permissions are required to adjust system settings."
|
||||||
|
echo -e "${CYAN_B}Please enter your password...${RESET}"
|
||||||
|
sudo -v
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo -e "${YELLOW}Exiting, as not being run as sudo${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check pacman actually installed
|
||||||
|
if ! hash pacman 2> /dev/null; then
|
||||||
|
echo "${YELLOW_B}Pacman doesn't seem to be present on your system. Exiting...${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt user to update package database
|
||||||
|
echo -e "${CYAN_B}Would you like to update package database? (y/N)${RESET}\n"
|
||||||
|
read -t $PROMPT_TIMEOUT -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${PURPLE}Updating dadatbase...${RESET}"
|
||||||
|
sudo pacman -Syy --noconfirm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt user to upgrade currently installed packages
|
||||||
|
echo -e "${CYAN_B}Would you like to upgrade currently installed packages? (y/N)${RESET}\n"
|
||||||
|
read -t $PROMPT_TIMEOUT -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${PURPLE}Upgrading installed packages...${RESET}"
|
||||||
|
sudo pacman -Syu --noconfirm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt user to clear old package caches
|
||||||
|
echo -e "${CYAN_B}Would you like to clear unused package caches? (y/N)${RESET}\n"
|
||||||
|
read -t $PROMPT_TIMEOUT -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${PURPLE}Freeing up disk space...${RESET}"
|
||||||
|
sudo pacman -Sc --noconfirm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt user to install all listed apps
|
||||||
|
echo -e "${CYAN_B}Would you like to install listed apps? (y/N)${RESET}\n"
|
||||||
|
read -t $PROMPT_TIMEOUT -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${PURPLE}Starting install...${RESET}"
|
||||||
|
for app in ${pacman_apps[@]}; do
|
||||||
|
if hash "${app}" 2> /dev/null; then
|
||||||
|
echo -e "${YELLOW}[Skipping]${LIGHT} ${app} is already installed${RESET}"
|
||||||
|
elif hash flatpak 2> /dev/null && [[ ! -z $(echo $(flatpak list --columns=ref | grep $app)) ]]; then
|
||||||
|
echo -e "${YELLOW}[Skipping]${LIGHT} ${app} is already installed via Flatpak${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${PURPLE}[Installing]${LIGHT} Downloading ${app}...${RESET}"
|
||||||
|
# pacman -S ${app} --noconfirm
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${PURPLE}Finished installing / updating Arch packages.${RESET}"
|
||||||
|
Loading…
Reference in New Issue
Block a user