fix all shellcheck warnings + formatting

This commit is contained in:
Jeevitha Kannan K S 2024-11-05 17:31:34 +05:30
parent 5878f4dbf0
commit d317d1e5cf
No known key found for this signature in database
GPG Key ID: 5904C34A2F7CE333
89 changed files with 871 additions and 901 deletions

View File

@ -16,7 +16,7 @@ install_adb() {
"$ESCALATION_TOOL" "$PACKAGER" install -y android-tools
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac

View File

@ -8,7 +8,7 @@ installLibreWolf() {
case "$PACKAGER" in
apt-get | nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y gnupg lsb-release apt-transport-https ca-certificates
distro=`if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi`
distro=$(if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi)
curl -fsSL https://deb.librewolf.net/keyring.gpg | "$ESCALATION_TOOL" gpg --dearmor -o /usr/share/keyrings/librewolf.gpg
echo "Types: deb
URIs: https://deb.librewolf.net

View File

@ -17,11 +17,11 @@ installDiscord() {
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
"$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm
"$ESCALATION_TOOL" "$PACKAGER" install -y discord
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac

View File

@ -7,8 +7,7 @@ installSignal() {
printf "%b\n" "${YELLOW}Installing Signal...${RC}"
case "$PACKAGER" in
apt-get | nala)
curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg >/dev/null
printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/signal-xenial.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" -y install signal-desktop

View File

@ -13,10 +13,22 @@ choose_installation() {
read -r CHOICE
case "$CHOICE" in
1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;;
2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;;
3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;;
*) printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"; exit 1 ;;
1)
INSTALL_DOCKER=1
INSTALL_COMPOSE=0
;;
2)
INSTALL_DOCKER=0
INSTALL_COMPOSE=1
;;
3)
INSTALL_DOCKER=1
INSTALL_COMPOSE=1
;;
*)
printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"
exit 1
;;
esac
}

View File

@ -105,7 +105,10 @@ picom_animations() {
printf "%b\n" "${GREEN}Repository already exists, skipping clone${RC}"
fi
cd "$HOME/.local/share/ftlabs-picom" || { printf "%b\n" "${RED}Failed to change directory to picom${RC}"; return 1; }
cd "$HOME/.local/share/ftlabs-picom" || {
printf "%b\n" "${RED}Failed to change directory to picom${RC}"
return 1
}
# Build the project
if ! meson setup --buildtype=release build; then
@ -192,7 +195,7 @@ setupDisplayManager() {
"$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
@ -226,7 +229,7 @@ setupDisplayManager() {
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
@ -241,7 +244,10 @@ install_slstatus() {
read -r response # -r flag to prevent backslashes from being interpreted
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
printf "%b\n" "${YELLOW}Installing slstatus${RC}"
cd "$HOME/dwm-titus/slstatus" || { printf "%b\n" "${RED}Failed to change directory to slstatus${RC}"; return 1; }
cd "$HOME/dwm-titus/slstatus" || {
printf "%b\n" "${RED}Failed to change directory to slstatus${RC}"
return 1
}
if "$ESCALATION_TOOL" make clean install; then
printf "%b\n" "${GREEN}slstatus installed successfully${RC}"
else

View File

@ -2,6 +2,7 @@
. ../common-script.sh
#shellcheck disable=SC1091
installLinutil() {
printf "%b\n" "${YELLOW}Installing Linutil...${RC}"
case "$PACKAGER" in
@ -43,11 +44,11 @@ installLinutil() {
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
. "$HOME/.cargo/env"
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
. "$HOME/.cargo/env"
;;
esac
fi
@ -58,6 +59,7 @@ installLinutil() {
;;
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
esac
;;
esac
}

View File

@ -2,6 +2,7 @@
. ../common-script.sh
#shellcheck disable=SC1091
updateLinutil() {
if [ ! -e "$HOME/.cargo/bin/linutil" ]; then
printf "%b\n" "${RED}This script only updates the binary installed through cargo.\nlinutil_tui is not installed.${RC}"
@ -17,7 +18,7 @@ updateLinutil() {
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. $HOME/.cargo/env
. "$HOME/.cargo/env"
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup

View File

@ -10,7 +10,7 @@ GREEN='\033[32m'
command_exists() {
for cmd in "$@"; do
export PATH=/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH
export PATH="/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH"
command -v "$cmd" >/dev/null 2>&1 || return 1
done
return 0
@ -160,6 +160,7 @@ checkDistro() {
DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
DTYPE=$ID
fi

View File

@ -86,7 +86,7 @@ select_option() {
fi
done
last_selected=$selected
last_selected="$selected"
# Read user input
read -rsn1 key
@ -96,13 +96,13 @@ select_option() {
case $key in
'[A') # Up arrow
((selected--))
if [ $selected -lt 0 ]; then
if [ "$selected" -lt 0 ]; then
selected=$((num_options - 1))
fi
;;
'[B') # Down arrow
((selected++))
if [ $selected -ge $num_options ]; then
if [ "$selected" -ge "$num_options" ]; then
selected=0
fi
;;
@ -151,7 +151,10 @@ filesystem () {
export FS=luks
;;
3) exit ;;
*) echo "Wrong option please select again"; filesystem;;
*)
echo "Wrong option please select again"
filesystem
;;
esac
}
@ -169,13 +172,18 @@ timezone () {
case ${options[$?]} in
y | Y | yes | Yes | YES)
echo "${time_zone} set as timezone"
export TIMEZONE=$time_zone;;
export TIMEZONE=$time_zone
;;
n | N | no | NO | No)
echo "Please enter your desired timezone e.g. Europe/London :"
read -r new_timezone
echo "${new_timezone} set as timezone"
export TIMEZONE=$new_timezone;;
*) echo "Wrong option. Try again";timezone;;
export TIMEZONE=$new_timezone
;;
*)
echo "Wrong option. Try again"
timezone
;;
esac
}
# @description Set user's keyboard mapping.
@ -183,7 +191,7 @@ keymap () {
echo -ne "
Please select key board layout from this list"
# These are default key maps as presented in official arch repo archinstall
options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk)
options=('us' 'by' 'ca' 'cf' 'cz' 'de' 'dk' 'es' 'et' 'fa' 'fi' 'fr' 'gr' 'hu' 'il' 'it' 'lt' 'lv' 'mk' 'nl' 'no' 'pl' 'ro' 'ru' 'se' 'sg' 'ua' 'uk')
select_option "${options[@]}"
keymap=${options[$?]}
@ -203,10 +211,15 @@ drivessd () {
case ${options[$?]} in
y | Y | yes | Yes | YES)
export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120";;
export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120"
;;
n | N | no | NO | No)
export MOUNT_OPTIONS="noatime,compress=zstd,commit=120";;
*) echo "Wrong option. Try again";drivessd;;
export MOUNT_OPTIONS="noatime,compress=zstd,commit=120"
;;
*)
echo "Wrong option. Try again"
drivessd
;;
esac
}
@ -225,6 +238,7 @@ echo -ne "
PS3='
Select the disk to install on: '
# shellcheck disable=SC2207
options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}'))
select_option "${options[@]}"
@ -239,19 +253,16 @@ echo -ne "
# @description Gather username and password to be used for installation.
userinfo() {
# Loop through user input until the user gives a valid username
while true
do
while true; do
read -r -p "Please enter username: " username
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]; then
break
fi
echo "Incorrect username."
done
export USERNAME=$username
while true
do
while true; do
read -rs -p "Please enter password: " PASSWORD1
echo -ne "\n"
read -rs -p "Please re-enter password: " PASSWORD2
@ -265,18 +276,15 @@ userinfo () {
export PASSWORD=$PASSWORD1
# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
while true; do
read -r -p "Please name your machine: " name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]; then
break
fi
# if validation fails allow the user to force saving of the hostname
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]]
then
if [[ "${force,,}" = "y" ]]; then
break
fi
done
@ -456,7 +464,7 @@ echo -ne "
Checking for low memory systems <8G
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
TOTAL_MEM=$(grep -i 'memtotal' /proc/meminfo | grep -o '[[:digit:]]*')
if [[ $TOTAL_MEM -lt 8000000 ]]; then
# Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything.
mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly.
@ -474,6 +482,7 @@ fi
gpu_type=$(lspci | grep -E "VGA|3D|Display")
# shellcheck disable=SC2154
arch-chroot /mnt /bin/bash -c "KEYMAP='${KEYMAP}' /bin/bash" <<EOF
echo -ne "
@ -500,7 +509,7 @@ echo -ne "
changing the compression settings.
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
TOTAL_MEM=$(grep -i 'memtotal' /proc/meminfo | grep -o '[[:digit:]]*')
if [[ $TOTAL_MEM -gt 8000000 ]]; then
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf

View File

@ -2,8 +2,8 @@
. ../common-script.sh
# shellcheck disable=SC2086
installDepend() {
## Check for dependencies.
DEPENDENCIES='tar tree multitail tldr trash-cli unzip cmake make jq'
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
case "$PACKAGER" in

View File

@ -1,6 +1,7 @@
#!/bin/sh -e
. ../../common-script.sh
# This script allows user to download proprietary drivers for nvidia in fedora
# It also disables nouveau nvidia drivers
@ -17,13 +18,9 @@ checkRepo() {
else
printf "%b\n" "${YELLOW}Nvidia non-free repository is not enabled. Enabling now...${RC}"
# Enable the repository
"$ESCALATION_TOOL" dnf config-manager --set-enabled "$REPO_ID"
# Refreshing repository list
"$ESCALATION_TOOL" dnf makecache
# Verify if the repository is enabled
if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then
printf "%b\n" "${GREEN}Nvidia non-free repository is now enabled...${RC}"
else
@ -48,11 +45,10 @@ installDriver() {
exit 0
fi
# NOTE:: Installing graphics driver.
"$ESCALATION_TOOL" dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y
printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}"
for i in $(seq 1 5); do
for _ in $(seq 1 5); do
if checkDriverInstallation; then
printf "%b\n" "${GREEN}Driver installed successfully.${RC}"
printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}"
@ -66,7 +62,6 @@ installDriver() {
}
# NOTE: A confirmation option to proceed or not
userConfirmation() {
printf "%b" "${YELLOW}Do you want to continue? (y/N): ${RC}"
read -r choice
@ -77,7 +72,7 @@ userConfirmation() {
return
;;
n | N)
printf "%b\n" "${RED} Exiting the Script ${RC}"
printf "%b\n" "${RED}Exiting the script.${RC}"
return
;;
*)
@ -87,7 +82,7 @@ userConfirmation() {
esac
}
printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}"
printf "%b\n" "${YELLOW}Warning! This script will enable nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}"
checkEnv
checkEscalationTool

View File

@ -1,14 +1,14 @@
#!/bin/sh -e
# shellcheck disable=SC2086
. ../common-script.sh
installDepend() {
# Check for dependencies
DEPENDENCIES='wine dbus'
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
case "$PACKAGER" in
pacman)
#Check for multilib
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
@ -94,8 +94,7 @@ installAdditionalDepend() {
DISTRO_DEPS='lutris'
"$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS
;;
*)
;;
*) ;;
esac
}

View File

@ -21,6 +21,7 @@ cleanup_system() {
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
# shellcheck disable=SC2046
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm >/dev/null 2>&1
;;
*)

View File

@ -20,8 +20,7 @@ fastUpdate() {
dtype_local="arch"
fi
"$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then
if "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root "$dtype_local" || [ ! -s /etc/pacman.d/mirrorlist ]; then
printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}"
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
fi
@ -30,7 +29,10 @@ fastUpdate() {
apt-get | nala)
"$ESCALATION_TOOL" apt-get update
if ! command_exists nala; then
"$ESCALATION_TOOL" apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
"$ESCALATION_TOOL" apt-get install -y nala || {
printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"
PACKAGER="apt-get"
}
fi
if [ "$PACKAGER" = "nala" ]; then
@ -49,7 +51,7 @@ fastUpdate() {
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
@ -75,7 +77,7 @@ updateSystem() {
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac

View File

@ -30,10 +30,12 @@ list_sessions() {
9) session="i3.desktop" ;;
10)
printf "%b" "Enter custom session name (e.g., mysession): "
read -r session ;;
read -r session
;;
*)
printf "%b\n" "Invalid option selected."
exit 1 ;;
exit 1
;;
esac
}

View File

@ -67,7 +67,6 @@ update_fstab() {
printf "%b\n" "$fstab_entry"
}
# Function to mount the drive
mount_drive() {
printf "%b\n" "Mounting the drive..."

View File

@ -2,13 +2,12 @@
. ../common-script.sh
# Function to check Bluez is installed
setupBluetooth() {
printf "%b\n" "${YELLOW}Installing Bluez...${RC}"
if ! command_exists bluetoothctl; then
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm bluez-utils
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm bluez-utils bluez
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y bluez
@ -18,7 +17,6 @@ setupBluetooth() {
printf "%b\n" "${GREEN}Bluez is already installed.${RC}"
fi
# Check if bluetooth service is running
if ! systemctl is-active --quiet bluetooth; then
printf "%b\n" "${YELLOW}Bluetooth service is not running. Starting it now...${RC}"
"$ESCALATION_TOOL" systemctl start bluetooth
@ -29,7 +27,6 @@ setupBluetooth() {
fi
}
# Function to display the main menu
main_menu() {
while true; do
clear
@ -56,7 +53,6 @@ main_menu() {
done
}
# Function to scan for devices
scan_devices() {
clear
printf "%b\n" "${YELLOW}Scanning for devices...${RC}"
@ -69,16 +65,14 @@ scan_devices() {
printf "%b\n" "$devices"
fi
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
}
# Function to prompt for MAC address using numbers
prompt_for_mac() {
action=$1
command=$2
prompt_msg=$3
success_msg=$4
failure_msg=$5
command=$1
prompt_msg=$2
success_msg=$3
failure_msg=$4
while true; do
clear
@ -86,7 +80,7 @@ prompt_for_mac() {
if [ -z "$devices" ]; then
printf "%b\n" "${RED}No devices available. Please scan for devices first.${RC}"
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
return
fi
@ -95,23 +89,24 @@ prompt_for_mac() {
i=1
echo "$device_list" | while IFS= read -r device; do
printf "%d. %s\n" "$i" "$device"
#shellcheck disable=SC2030
i=$((i + 1))
done
printf "%b\n" "0. Exit to main menu"
printf "%b\n" "$prompt_msg"
read -r choice
# Validate the choice
# shellcheck disable=SC2031
if echo "$choice" | grep -qE '^[0-9]+$' && [ "$choice" -le "$((i - 1))" ] && [ "$choice" -gt 0 ]; then
device=$(echo "$device_list" | sed -n "${choice}p")
mac=$(echo "$device" | awk '{print $2}')
if bluetoothctl info "$mac" >/dev/null 2>&1; then
bluetoothctl "$command" "$mac" && {
if bluetoothctl "$command" "$mac"; then
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
else
printf "%b\n" "${RED}$failure_msg${RC}"
}
fi
else
printf "%b\n" "${RED}Invalid MAC address. Please try again.${RC}"
fi
@ -122,30 +117,25 @@ prompt_for_mac() {
fi
done
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
}
# Function to pair with a device
pair_device() {
prompt_for_mac "pair" "pair" "Enter the number of the device to pair: " "Pairing with device completed." "Failed to pair with device."
prompt_for_mac "pair" "Enter the number of the device to pair: " "Pairing with device completed." "Failed to pair with device."
}
# Function to connect to a device
connect_device() {
prompt_for_mac "connect" "connect" "Enter the number of the device to connect: " "Connecting to device completed." "Failed to connect to device."
prompt_for_mac "connect" "Enter the number of the device to connect: " "Connecting to device completed." "Failed to connect to device."
}
# Function to disconnect from a device
disconnect_device() {
prompt_for_mac "disconnect" "disconnect" "Enter the number of the device to disconnect: " "Disconnecting from device completed." "Failed to disconnect from device."
prompt_for_mac "disconnect" "Enter the number of the device to disconnect: " "Disconnecting from device completed." "Failed to disconnect from device."
}
# Function to remove a device
remove_device() {
prompt_for_mac "remove" "remove" "Enter the number of the device to remove: " "Removing device completed." "Failed to remove device."
prompt_for_mac "remove" "Enter the number of the device to remove: " "Removing device completed." "Failed to remove device."
}
# Initialize
checkEnv
checkEscalationTool
setupBluetooth

View File

@ -4,7 +4,6 @@
CONFIGURATION_URL="https://github.com/quickemu-project/quickget_configs/releases/download/daily/quickget_data.json"
# Function to display all available block devices
list_devices() {
printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}"
printf "\n"
@ -12,17 +11,21 @@ list_devices() {
printf "\n"
}
# shellcheck disable=SC2086
installDependencies() {
DEPENDENCIES="xz gzip bzip2 jq"
if ! command_exists ${DEPENDENCIES}; then
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
case "${PACKAGER}" in
apt-get | nala)
"${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq;;
"${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq
;;
dnf | zypper)
"${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES};;
"${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES}
;;
pacman)
"${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES};;
"${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES}
;;
*)
printf "%b\n" "${RED}Unsupported package manager.${RC}"
exit 1
@ -31,7 +34,6 @@ installDependencies() {
fi
}
# Function to ask whether to use local or online ISO
choose_iso_source() {
printf "%b\n" "${YELLOW} Do you want to use a local ISO or download online? ${RC}"
printf "1) Download online\n"
@ -64,13 +66,16 @@ decompress_iso() {
case "${ISO_ARCHIVE_FORMAT}" in
xz)
xz -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')";;
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')"
;;
gz)
gzip -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')";;
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')"
;;
bz2)
bzip2 -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')";;
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')"
;;
*)
printf "%b\n" "${RED}Unsupported archive format. Try manually decompressing the ISO and choosing it as a local file instead.${RC}"
exit 1
@ -86,8 +91,10 @@ check_hash() {
40) HASH_ALGO="sha1sum" ;;
64) HASH_ALGO="sha256sum" ;;
128) HASH_ALGO="sha512sum" ;;
*) printf "%b\n" "${RED}Invalid checksum length. Skipping checksum verification.${RC}"
return;;
*)
printf "%b\n" "${RED}Invalid checksum length. Skipping checksum verification.${RC}"
return
;;
esac
printf "%b\n" "Checking ISO integrity using ${HASH_ALGO}..."
if ! echo "${ISO_CHECKSUM} ${ISO_PATH}" | "${HASH_ALGO}" --check --status; then
@ -211,25 +218,19 @@ get_online_iso() {
write_iso() {
clear
# Ask whether to use a local or online ISO
choose_iso_source
clear
# Display all available devices
list_devices
# Prompt user for USB device
printf "%b" "Enter the USB device (e.g. /dev/sdX): "
read -r USB_DEVICE
# Verify that the USB device exists
if [ ! -b "$USB_DEVICE" ]; then
printf "%b\n" "${RED}USB device not found: $USB_DEVICE${RC}"
exit 1
fi
# Confirm the device selection with the user
printf "%b" "${RED}WARNING: This will erase all data on ${USB_DEVICE}. Are you sure you want to continue? (y/N): ${RC}"
read -r CONFIRMATION
@ -238,14 +239,12 @@ write_iso(){
exit 1
fi
# Display progress and create the bootable USB drive
printf "%b\n" "${YELLOW}Creating bootable USB drive...${RC}"
if ! "$ESCALATION_TOOL" dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then
printf "%b\n" "${RED}Failed to create bootable USB drive${RC}"
exit 1
fi
# Sync to ensure all data is written
if ! "$ESCALATION_TOOL" sync; then
printf "%b\n" "${RED}Failed to sync data${RC}"
exit 1
@ -253,7 +252,6 @@ write_iso(){
printf "%b\n" "${GREEN}Bootable USB drive created successfully!${RC}"
# Eject the USB device
printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}"
if ! "$ESCALATION_TOOL" umount "${USB_DEVICE}"* 2>/dev/null; then
printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}"

View File

@ -1,10 +1,11 @@
#!/bin/sh -e
# shellcheck disable=SC2181
. ../common-script.sh
# Function to display the menu
printf "%b\n" "${YELLOW}Ensuring OpenSSL is installed...${RC}"
# Install OpenSSL
if ! command_exists openssl; then
case "$PACKAGER" in
pacman)
@ -40,7 +41,6 @@ show_menu() {
printf "%b\n" "========================================================"
}
# Function to encrypt a file
encrypt_file() {
printf "%b" "Enter the path to the file or directory to encrypt: "
read -r INPUT_PATH
@ -59,15 +59,12 @@ encrypt_file() {
if [ -d "$INPUT_PATH" ]; then
# Encrypt each file in the directory
find "$INPUT_PATH" -type f | while read -r FILE; do
REL_PATH="${FILE#$INPUT_PATH/}"
REL_PATH="${FILE#"$INPUT_PATH"/}"
OUTPUT_FILE="$OUTPUT_PATH/$REL_PATH.enc"
mkdir -p "$(dirname "$OUTPUT_FILE")"
openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD"
if [ $? -eq 0 ]; then
printf "%b\n" "Encrypted: $OUTPUT_FILE"
else
printf "%b\n" "Failed to encrypt: $FILE"
fi
done
else
# Encrypt a single file
@ -77,15 +74,11 @@ encrypt_file() {
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD"
if [ $? -eq 0 ]; then
printf "%b\n" "Encrypted: $OUTPUT_PATH"
else
printf "%b\n" "Failed to encrypt: $INPUT_PATH"
fi
fi
}
# Function to decrypt a file
decrypt_file() {
printf "%b" "Enter the path to the file or directory to decrypt: "
read -r INPUT_PATH
@ -104,15 +97,12 @@ decrypt_file() {
if [ -d "$INPUT_PATH" ]; then
# Decrypt each file in the directory
find "$INPUT_PATH" -type f -name '*.enc' | while read -r FILE; do
REL_PATH="${FILE#$INPUT_PATH/}"
REL_PATH="${FILE#"$INPUT_PATH"/}"
OUTPUT_FILE="$OUTPUT_PATH/${REL_PATH%.enc}"
mkdir -p "$(dirname "$OUTPUT_FILE")"
openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD"
if [ $? -eq 0 ]; then
printf "%b\n" "Decrypted: $OUTPUT_FILE"
else
printf "%b\n" "Failed to decrypt: $FILE"
fi
done
else
# Decrypt a single file
@ -122,11 +112,8 @@ decrypt_file() {
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD"
if [ $? -eq 0 ]; then
printf "%b\n" "Decrypted: $OUTPUT_PATH"
else
printf "%b\n" "Failed to decrypt: $INPUT_PATH"
fi
fi
}
@ -140,12 +127,15 @@ main(){
case $CHOICE in
1) encrypt_file ;;
2) decrypt_file ;;
3) printf "%b\n" "Exiting..."; exit 0 ;;
3)
printf "%b\n" "Exiting..."
exit 0
;;
*) printf "%b\n" "Invalid choice. Please try again." ;;
esac
printf "%b\n" "Press [Enter] to continue..."
read -r dummy
read -r _
done
}

View File

@ -47,7 +47,10 @@ change_orientation() {
2) orientation="left" ;;
3) orientation="right" ;;
4) orientation="inverted" ;;
*) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;;
*)
printf "%b\n" "${RED}Invalid selection.${RC}"
return
;;
esac
if confirm_action "Change orientation of $monitor_name to $orientation?"; then

View File

@ -45,7 +45,10 @@ manage_arrangement() {
2) position="--right-of" ;;
3) position="--above" ;;
4) position="--below" ;;
*) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;;
*)
printf "%b\n" "${RED}Invalid selection.${RC}"
return
;;
esac
printf "%b\n" "${YELLOW}Choose the reference monitor:${RC}"

View File

@ -29,7 +29,7 @@ adjust_monitor_brightness() {
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
printf "Press [Enter] to continue..."
read -r dummy
read -r _
continue
fi
@ -37,7 +37,7 @@ adjust_monitor_brightness() {
if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$monitor_count" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
printf "Press [Enter] to continue..."
read -r dummy
read -r _
continue
fi

View File

@ -4,7 +4,6 @@
. ../../common-script.sh
# Function to set resolutions
set_resolutions() {
monitor_list=$(detect_connected_monitors)
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
@ -33,7 +32,7 @@ set_resolutions() {
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
printf "%b\n" "Press [Enter] to continue..."
read -r dummy
read -r _
continue
fi

View File

@ -39,7 +39,6 @@ EOF
}
numlockSetup() {
# Check if the script and service files exists
if [ ! -f "/usr/local/bin/numlock" ]; then
create_file
fi

View File

@ -52,7 +52,6 @@ display_models() {
printf "%b\n" "16. Solar - 10.7B (6.1GB)"
}
# Function to select model based on user input
select_model() {
choice="$1"
case $choice in
@ -82,10 +81,11 @@ run_model() {
printf "%b\n" "${GREEN}Installed Models${RC}"
installed_models=$(ollama list)
printf "%b\n" "${installed_models}"
printf "%b\n" "$installed_models"
printf "%b\n" "${YELLOW}Custom Models${RC}"
custom_models=$(ollama list | grep 'custom-model-prefix')
printf "%b\n" "$custom_models"
printf "%b" "Select a model to run: "
printf "%b" "Enter the number corresponding to the model or enter the name of a custom model: "
@ -103,7 +103,6 @@ create_model() {
printf "%b\n" "${YELLOW}Let's create a new model in Ollama!${RC}"
display_models
# Prompt for base model
printf "%b" "Enter the base model (e.g. '13' for codellama): "
read -r base_model
@ -112,11 +111,9 @@ create_model() {
printf "%b\n" "${YELLOW}Running the model: $model...${RC}"
ollama pull "$model"
# Prompt for custom model name
printf "%b" "Enter a name for the new customized model: "
read -r custom_model_name
# Prompt for temperature setting
printf "%b" "Enter the desired temperature (higher values are more creative, lower values are more coherent, e.g., 1): "
read -r temperature
@ -124,11 +121,9 @@ create_model() {
temperature=${temperature:-1}
fi
# Prompt for system message
printf "%b" "Enter the system message for the model customization (e.g., 'You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.'): "
read -r system_message
# Create the Modelfile
printf "%b\n" "${YELLOW}Creating the Modelfile...${RC}"
cat <<EOF >Modelfile
FROM $base_model
@ -142,13 +137,11 @@ $system_message
"""
EOF
# Create the model in Ollama
printf "%b\n" "${YELLOW}Creating the model in Ollama...${RC}"
ollama create "$custom_model_name" -f Modelfile
printf "%b\n" "${GREEN}Model '$custom_model_name' created successfully.${RC}"
}
# Function to remove a model
remove_model() {
clear
printf "%b\n" "${GREEN}Installed Models${RC}"
@ -190,12 +183,15 @@ menu() {
3) create_model ;;
4) run_model ;;
5) remove_model ;;
6) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;;
6)
printf "%b\n" "${GREEN}Exiting...${RC}"
exit 0
;;
*) printf "%b\n" "${RED}Invalid choice. Please try again.${RC}" ;;
esac
printf "%b\n" "${YELLOW}Press Enter to continue...${RC}"
read -r dummy
read -r _
done
}
@ -203,4 +199,3 @@ checkEnv
checkEscalationTool
installollama
menu

View File

@ -5,18 +5,18 @@
# Function to install packages based on the package manager
install_package() {
PACKAGE=$1
if ! command_exists "$PACKAGE"; then
package=$1
if ! command_exists "$package"; then
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$PACKAGE"
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$package"
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$PACKAGE"
"$ESCALATION_TOOL" "$PACKAGER" install -y "$package"
;;
esac
else
echo "$PACKAGE is already installed."
echo "$package is already installed."
fi
}
@ -171,7 +171,7 @@ setup_ssh_samba(){
printf "%b\n" "5. Exit"
printf "%b" "Enter your choice (1-5): "
read CHOICE
read -r CHOICE
case "$CHOICE" in
1)

View File

@ -262,12 +262,15 @@ main() {
8) enable_service ;;
9) disable_service ;;
10) create_service_from_external ;;
11) printf "%b\n" "Exiting..."; exit 0 ;;
11)
printf "%b\n" "Exiting..."
exit 0
;;
*) printf "%b\n" "Invalid choice. Please try again." ;;
esac
printf "%b\n" "Press [Enter] to continue..."
read -r dummy
read -r _
done
}

View File

@ -2,21 +2,18 @@
. ../common-script.sh
# Check if ~/.ssh/config exists, if not, create it
if [ ! -f ~/.ssh/config ]; then
mkdir -p "$HOME/.ssh"
touch "$HOME/.ssh/config"
chmod 600 "$HOME/.ssh/config"
fi
# Function to show available hosts from ~/.ssh/config
show_available_hosts() {
printf "%b\n" "Available Systems:"
grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}'
printf "%b\n" "-------------------"
}
# Function to ask for host details
ask_for_host_details() {
printf "%b" "Enter Host Alias: "
read -r host_alias
@ -35,7 +32,6 @@ ask_for_host_details() {
printf "%b\n" "Host $host_alias added successfully."
}
# Function to generate SSH key if not exists
generate_ssh_key() {
if [ ! -f ~/.ssh/id_rsa ]; then
printf "%b\n" "SSH key not found, generating one..."
@ -45,7 +41,6 @@ generate_ssh_key() {
fi
}
# Function to share the SSH public key with the remote host
share_ssh_key() {
printf "%b" "Enter the alias of the host to copy the key to: "
read -r host_alias
@ -54,19 +49,18 @@ share_ssh_key() {
printf "%b\n" "SSH key copied to $host_alias successfully."
}
# Function to disable password authentication and allow only SSH keys
#repeated twice as changes should take place when in commented state or modified state.
disable_password_auth() {
printf "%b\n" "Disabling SSH password authentication and enabling key-only login..."
printf "%b\n" "Enter the alias of the host: "
read -r host_alias
printf "\n"
# shellcheck disable=SC2029
ssh "$host_alias" "
"$ESCALATION_TOOL" -S sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S systemctl restart sshd
$ESCALATION_TOOL -S sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S systemctl restart sshd
"
printf "%b\n" "PasswordAuthentication set to no and PubkeyAuthentication set to yes."
}
@ -76,12 +70,13 @@ enable_password_auth() {
printf "%b\n" "Enter the alias of the host: "
read -r host_alias
printf "\n"
# shellcheck disable=SC2029
ssh "$host_alias" "
"$ESCALATION_TOOL" -S sed -i 's/^#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S sed -i 's/^PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config &&
"$ESCALATION_TOOL" -S systemctl restart sshd
$ESCALATION_TOOL -S sed -i 's/^#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S sed -i 's/^PubkeyAuthentication yes/PubkeyAuthentication no/' /etc/ssh/sshd_config &&
$ESCALATION_TOOL -S systemctl restart sshd
"
printf "%b\n" "PasswordAuthentication set to yes and PubkeyAuthentication set to no."
}
@ -99,6 +94,7 @@ run_remote_command() {
read -r host_alias
printf "%b" "Enter the command to run: "
read -r remote_command
# shellcheck disable=SC2029
ssh "$host_alias" "$remote_command"
}
@ -124,7 +120,6 @@ copy_directory_to_remote() {
scp -r "$local_dir" "$host_alias:$remote_path"
}
# Function to move a file to a remote server (copy and delete local)
move_file_to_remote() {
printf "%b" "Enter the local file path: "
@ -226,7 +221,10 @@ main() {
read -r choice
case $choice in
1) ask_for_host_details ;;
2) show_available_hosts && printf "%b" "Enter the alias of the host to connect to: " && read -r host_alias; ssh "$host_alias" ;;
2)
show_available_hosts && printf "%b" "Enter the alias of the host to connect to: " && read -r host_alias
ssh "$host_alias"
;;
3) generate_ssh_key ;;
4) share_ssh_key ;;
5) disable_password_auth ;;

View File

@ -2,7 +2,6 @@
. ../common-script.sh
# Function to install Timeshift
install_timeshift() {
clear
printf "%b\n" "${YELLOW}Checking if Timeshift is installed...${RC}"
@ -21,7 +20,6 @@ install_timeshift() {
fi
}
# Function to display the menu
display_menu() {
clear
printf "%b\n" "${CYAN}Timeshift CLI Automation${RC}"
@ -34,19 +32,16 @@ display_menu() {
printf "%b\n" "${CYAN}7) Exit${RC}"
}
# Function to list snapshots
list_snapshots() {
printf "%b\n" "${CYAN}Listing snapshots...${RC}"
"$ESCALATION_TOOL" timeshift --list-snapshots
}
# Function to list devices
list_devices() {
printf "%b\n" "${CYAN}Listing available devices...${RC}"
"$ESCALATION_TOOL" timeshift --list-devices
}
# Function to create a new snapshot
create_snapshot() {
printf "%b" "${CYAN}Enter a comment for the snapshot (optional): ${RC}"
read -r COMMENT
@ -64,14 +59,9 @@ create_snapshot() {
"$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" --tags "$TAG"
fi
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot created successfully.${RC}"
else
printf "%b\n" "${RED}Snapshot creation failed.${RC}"
fi
}
# Function to restore a snapshot
restore_snapshot() {
list_snapshots
@ -90,14 +80,9 @@ restore_snapshot() {
"$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes
fi
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}"
else
printf "%b\n" "${RED}Snapshot restore failed.${RC}"
fi
}
# Function to delete a snapshot
delete_snapshot() {
list_snapshots
@ -107,14 +92,9 @@ delete_snapshot() {
printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}"
"$ESCALATION_TOOL" timeshift --delete --snapshot "$SNAPSHOT" --yes
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}"
else
printf "%b\n" "${RED}Snapshot deletion failed.${RC}"
fi
}
# Function to delete all snapshots
delete_all_snapshots() {
printf "%b\n" "${RED}WARNING: This will delete all snapshots!${RC}"
printf "%b" "${CYAN}Are you sure? (y/N): ${RC}"
@ -123,11 +103,7 @@ delete_all_snapshots() {
if [ "$CONFIRMATION" = "y" ] || [ "$CONFIRMATION" = "Y" ]; then
printf "%b\n" "${CYAN}Deleting all snapshots...${RC}"
"$ESCALATION_TOOL" timeshift --delete-all --yes
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}"
else
printf "%b\n" "${RED}Failed to delete snapshots.${RC}"
fi
else
printf "%b\n" "${RED}Operation cancelled.${RC}"
fi
@ -146,11 +122,14 @@ main_menu() {
4) restore_snapshot ;;
5) delete_snapshot ;;
6) delete_all_snapshots ;;
7) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;;
7)
printf "%b\n" "${GREEN}Exiting...${RC}"
exit 0
;;
*) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;;
esac
printf "%b\n" "${CYAN}Press Enter to continue...${RC}"
read -r dummy
read -r _
done
}

View File

@ -33,7 +33,7 @@ addToGroup() {
groups_to_add=$(echo "$groups" | tr ' ' ',')
printf "%b" "${YELLOW}Are you sure you want to add user $username to $groups_to_add? [Y/n]: ${RC}"
read -r confirm
read -r _
confirmAction || exit 1
"$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username"

View File

@ -17,7 +17,7 @@ changePassword() {
read -r password
printf "%b" "${YELLOW}Are you sure you want to change password for ""$username""? [Y/n]: ${RC}"
read -r confirm
read -r _
confirmAction || exit 1
echo "$username:$password" | "$ESCALATION_TOOL" chpasswd

View File

@ -14,10 +14,10 @@ deleteUser() {
if id "$username" >/dev/null 2>&1; then
printf "%b" "${YELLOW}Are you sure you want to delete user ""$username""? [Y/n]: ${RC}"
read -r confirm
read -r _
confirmAction || exit 1
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
"$ESCALATION_TOOL" userdel --remove "$username" 2>/dev/null
printf "%b\n" "${GREEN}User $username deleted successfully${RC}"
else
printf "%b\n" "${RED}User $username does not exist.${RC}"

View File

@ -34,10 +34,11 @@ removeFromGroup() {
groups_to_remove=$(echo "$groups" | tr ' ' ',')
printf "%b" "${YELLOW}Are you sure you want to remove user $username from $groups_to_remove? [Y/n]: ${RC}"
read -r confirm
read -r _
confirmAction || exit 1
$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
# shellcheck disable=SC2086
"$ESCALATION_TOOL" usermod -rG $groups_to_remove "$username"
printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}"
}

View File

@ -2,7 +2,6 @@
. ../../common-script.sh
# Function to check xrandr is installed
setup_xrandr() {
printf "%b\n" "${YELLOW}Installing xrandr...${RC}"
if ! command_exists xrandr; then
@ -22,29 +21,26 @@ setup_xrandr() {
fi
}
# Function to execute xrandr commands and handle errors
execute_command() {
command="$1"
printf "Executing: %s\n" "$command"
eval "$command" 2>&1 | tee /tmp/xrandr.log | tail -n 20
#shellcheck disable=SC2181
if [ $? -ne 0 ]; then
printf "%b\n" "${RED}An error occurred while executing the command. Check /tmp/xrandr.log for details.${RC}"
fi
}
# Function to detect connected monitors
detect_connected_monitors() {
xrandr_output=$(xrandr)
printf "%b\n" "$xrandr_output" | grep " connected" | awk '{print $1}'
}
# Function to get the current brightness for a monitor
get_current_brightness() {
monitor="$1"
xrandr --verbose | grep -A 10 "^$monitor connected" | grep "Brightness:" | awk '{print $2}'
}
# Function to get resolutions for a monitor
get_unique_resolutions() {
monitor="$1"
xrandr_output=$(xrandr)
@ -71,7 +67,6 @@ get_unique_resolutions() {
printf "%b\n" "$filtered_standard_resolutions\n$remaining_resolutions" | head -n 10
}
# Function to prompt for confirmation
confirm_action() {
action="$1"
printf "%b\n" "${CYAN}$action${RC}"

View File

@ -2,7 +2,6 @@
. ../common-script.sh
# Function to check if NetworkManager is installed
setupNetworkManager() {
printf "%b\n" "${YELLOW}Installing NetworkManager...${RC}"
if ! command_exists nmcli; then
@ -21,7 +20,6 @@ setupNetworkManager() {
printf "%b\n" "${YELLOW}NetworkManager is already installed.${RC}"
fi
# Check if NetworkManager service is running
if ! systemctl is-active --quiet NetworkManager; then
printf "%b\n" "${YELLOW}NetworkManager service is not running. Starting it now...${RC}"
"$ESCALATION_TOOL" systemctl start NetworkManager
@ -32,7 +30,6 @@ setupNetworkManager() {
fi
}
# Function to display the main menu
main_menu() {
while true; do
clear
@ -61,7 +58,6 @@ main_menu() {
done
}
# Function to scan for WiFi networks
scan_networks() {
clear
printf "%b\n" "${YELLOW}Scanning for WiFi networks...${RC}"
@ -73,36 +69,33 @@ scan_networks() {
echo "$networks" | awk -F: '{printf("%d. SSID: %-25s \n", NR, $1)}'
fi
printf "%b\n" "Press any key to return to the main menu..."
read -r dummy
read -r _
}
# Function to turn WiFi on
wifi_on() {
clear
printf "%b\n" "${YELLOW}Turning WiFi on...${RC}"
nmcli radio wifi on && {
if nmcli radio wifi on; then
printf "%b\n" "${GREEN}WiFi is now turned on.${RC}"
} || {
else
printf "%b\n" "${RED}Failed to turn on WiFi.${RC}"
}
fi
printf "%b\n" "Press any key to return to the main menu..."
read -r dummy
read -r _
}
# Function to turn WiFi off
wifi_off() {
clear
printf "%b\n" "${YELLOW}Turning WiFi off...${RC}"
nmcli radio wifi off && {
if nmcli radio wifi off; then
printf "%b\n" "${GREEN}WiFi is now turned off.${RC}"
} || {
else
printf "%b\n" "${RED}Failed to turn off WiFi.${RC}"
}
fi
printf "%b\n" "Press any key to return to the main menu..."
read -r dummy
read -r _
}
# Function to prompt for WiFi network selection
prompt_for_network() {
action=$1
prompt_msg=$2
@ -116,7 +109,7 @@ prompt_for_network() {
if [ -z "$networks" ]; then
printf "%b\n" "${RED}No networks available. Please scan for networks first.${RC}"
printf "%b\n" "Press any key to return to the main menu..."
read -r dummy
read -r _
rm -f "$temp_file"
return
fi
@ -140,39 +133,35 @@ prompt_for_network() {
printf "%b" "Enter password for SSID: " "$ssid"
read -r password
printf "\n"
nmcli dev wifi connect "$ssid" password "$password" && {
printf "%b\n" "${GREEN}$success_msg${RC}"
} || {
printf "%b\n" "${RED}$failure_msg${RC}"
}
if nmcli dev wifi connect "$ssid" password "$password"; then
printf "%b\n" "${GREEN}${success_msg}${RC}"
else
printf "%b\n" "${RED}${failure_msg}${RC}"
fi
fi
else
printf "%b\n" "${RED}Invalid choice. Please try again.${RC}"
fi
printf "%b\n" "Press any key to return to the selection menu..."
read -r dummy
read -r _
done
rm -f "$temp_file"
}
# Function to connect to a WiFi network
connect_network() {
prompt_for_network "connect" "Enter the number of the network to connect: " "Connected to the network successfully." "Failed to connect to the network."
}
# Function to disconnect from a WiFi network
disconnect_network() {
prompt_for_network "disconnect" "Enter the number of the network to disconnect: " "Disconnected from the network successfully." "Failed to disconnect from the network."
}
# Function to remove a WiFi connection
remove_network() {
prompt_for_network "remove" "Enter the number of the network to remove: " "Network removed successfully." "Failed to remove the network."
}
# Initialize
checkEnv
checkEscalationTool
setupNetworkManager

View File

@ -22,7 +22,7 @@ findArch() {
case "$(uname -m)" in
x86_64 | amd64) arch="x86_64" ;;
aarch64 | arm64) arch="aarch64" ;;
*) check 1 "Unsupported architecture"
*) check 1 "Unsupported architecture" ;;
esac
}

View File

@ -52,7 +52,7 @@ findArch() {
case "$(uname -m)" in
x86_64 | amd64) arch="x86_64" ;;
aarch64 | arm64) arch="aarch64" ;;
*) check 1 "Unsupported architecture"
*) check 1 "Unsupported architecture" ;;
esac
}