Skip to content

Commit

Permalink
refact: fix (almost) all shellcheck errors
Browse files Browse the repository at this point in the history
the only files i didn't fix:
- core/tabs/utils/ssh.sh (ref #996)
- core/tabs/system-setup/arch/server-setup.sh
  • Loading branch information
adamperkowski committed Jan 11, 2025
1 parent d91a44e commit 1fe60f5
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 74 deletions.
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/android-debloat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install_adb() {
"$ESCALATION_TOOL" "$PACKAGER" add android-tools
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/browsers/librewolf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,4 +49,4 @@ Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/
checkEnv
checkEscalationTool
checkAURHelper
installLibreWolf
installLibreWolf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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
;;
apk)
Expand All @@ -36,4 +36,4 @@ installDiscord() {

checkEnv
checkEscalationTool
installDiscord
installDiscord
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ installSignal() {
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
"$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg < 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
Expand Down Expand Up @@ -39,4 +39,4 @@ installSignal() {

checkEnv
checkEscalationTool
installSignal
installSignal
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/dwmtitus-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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
Expand Down Expand Up @@ -244,7 +244,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
Expand Down
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/linutil-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ installLinutil() {
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
. "$HOME/.cargo/env"
;;
esac
fi
Expand Down
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/linutil-updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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"
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base
Expand Down
3 changes: 2 additions & 1 deletion core/tabs/system-setup/arch/server-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ select_option() {
;;
'[B') # Down arrow
((selected++))
if [ $selected -ge $num_options ]; then
if [ $selected -ge "$num_options" ]; then
selected=0
fi
;;
Expand Down Expand Up @@ -183,6 +183,7 @@ keymap () {
echo -ne "
Please select key board layout from this list"
# These are default key maps as presented in official arch repo archinstall
# shellcheck disable=SC1010
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[@]}"
Expand Down
12 changes: 6 additions & 6 deletions core/tabs/system-setup/compile-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ installDepend() {
else
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
fi
"$AUR_HELPER" -S --needed --noconfirm $DEPENDENCIES
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
;;
apt-get|nala)
COMPILEDEPS='build-essential'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" dpkg --add-architecture i386
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
;;
dnf)
COMPILEDEPS='@development-tools'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
;;
zypper)
COMPILEDEPS='patterns-devel-base-devel_basis'
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base multitail tar tree trash-cli unzip cmake jq
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
;;
esac
}

checkEnv
checkAURHelper
checkEscalationTool
installDepend
installDepend
2 changes: 1 addition & 1 deletion core/tabs/system-setup/system-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cleanup_system() {
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null || true
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm > /dev/null || true
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" cache clean
Expand Down
15 changes: 7 additions & 8 deletions core/tabs/utils/bluetooth-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ 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
Expand All @@ -82,14 +81,14 @@ 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

# Display devices with numbers
device_list=$(echo "$devices" | tr '\n' '\n')
i=1
echo "$device_list" | while IFS= read -r device; do
for device in $device_list; do
printf "%d. %s\n" "$i" "$device"
i=$((i + 1))
done
Expand All @@ -102,12 +101,12 @@ prompt_for_mac() {
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
Expand All @@ -118,7 +117,7 @@ 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
Expand Down
24 changes: 12 additions & 12 deletions core/tabs/utils/encrypt_decrypt_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ 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

if [ "$(openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD")" -eq 0 ]; then
printf "%b\n" "Encrypted: $OUTPUT_FILE"
else
printf "%b\n" "Failed to encrypt: $FILE"
Expand All @@ -79,8 +79,8 @@ encrypt_file() {
return
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

if [ "$(openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD")" -eq 0 ]; then
printf "%b\n" "Encrypted: $OUTPUT_PATH"
else
printf "%b\n" "Failed to encrypt: $INPUT_PATH"
Expand All @@ -107,11 +107,11 @@ 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

if [ "$(openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD")" -eq 0 ]; then
printf "%b\n" "Decrypted: $OUTPUT_FILE"
else
printf "%b\n" "Failed to decrypt: $FILE"
Expand All @@ -124,8 +124,8 @@ decrypt_file() {
return
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

if [ "$(openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD")" -eq 0 ]; then
printf "%b\n" "Decrypted: $OUTPUT_PATH"
else
printf "%b\n" "Failed to decrypt: $INPUT_PATH"
Expand All @@ -148,10 +148,10 @@ main(){
esac

printf "%b\n" "Press [Enter] to continue..."
read -r dummy
read -r _
done
}

checkEnv
checkEscalationTool
main
main
4 changes: 2 additions & 2 deletions core/tabs/utils/monitor-control/set_brightness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ 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

monitor_count=$(echo "$monitor_list" | wc -l)
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

Expand Down
2 changes: 1 addition & 1 deletion core/tabs/utils/monitor-control/set_resolutions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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

Expand Down
5 changes: 3 additions & 2 deletions core/tabs/utils/ollama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ run_model() {
printf "%b\n" "${installed_models}"

printf "%b\n" "${YELLOW}Custom Models${RC}"
custom_models=$(ollama list | grep 'custom-model-prefix')
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: "
Expand Down Expand Up @@ -195,7 +196,7 @@ menu() {
esac

printf "%b\n" "${YELLOW}Press Enter to continue...${RC}"
read -r dummy
read -r _
done
}

Expand Down
4 changes: 2 additions & 2 deletions core/tabs/utils/samba-ssh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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)
Expand Down Expand Up @@ -205,4 +205,4 @@ setup_ssh_samba(){

checkEnv
checkEscalationTool
setup_ssh_samba
setup_ssh_samba
4 changes: 2 additions & 2 deletions core/tabs/utils/service-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ main() {
esac

printf "%b\n" "Press [Enter] to continue..."
read -r dummy
read -r _
done
}

checkEnv
checkEscalationTool
main
main
2 changes: 1 addition & 1 deletion core/tabs/utils/ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ done

checkEnv
checkEscalationTool
main
main
Loading

0 comments on commit 1fe60f5

Please sign in to comment.