Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bashisms #512

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ installDriver() {
$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 {1..5}; do
for i 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}"
Expand Down Expand Up @@ -91,4 +91,4 @@ printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free reposit

checkEnv
checkEscalationTool
userConfirmation
userConfirmation
12 changes: 6 additions & 6 deletions tabs/utils/encrypt_decrypt_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ encrypt_file() {
echo "Enter the path for the encrypted file or directory:"
read -r OUTPUT_PATH

echo "Enter the encryption password:"
read -s -r PASSWORD
printf "Enter the encryption password: "
read -r PASSWORD

if [ -d "$INPUT_PATH" ]; then
# Encrypt each file in the directory
Expand Down Expand Up @@ -99,8 +99,8 @@ decrypt_file() {
echo "Enter the path for the decrypted file or directory:"
read -r OUTPUT_PATH

echo "Enter the decryption password:"
read -s -r PASSWORD
printf "Enter the decryption password: "
read -r PASSWORD

if [ -d "$INPUT_PATH" ]; then
# Decrypt each file in the directory
Expand Down Expand Up @@ -145,8 +145,8 @@ main(){
*) echo "Invalid choice. Please try again." ;;
esac

echo "Press [Enter] to continue..."
read -r
printf "Press [Enter] to continue..."
read -r dummy
done
}

Expand Down
3 changes: 2 additions & 1 deletion tabs/utils/user-account-manager/add_to_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ checkGroupAvailabe "$groups" "$available_groups" || exit 1

groups_to_add=$(echo "$groups" | tr ' ' ',')

read -p "Are you sure you want to add user $username to $groups_to_add? [Y/N]: " confirm
printf "Are you sure you want to add user $username to $groups_to_add? [Y/N]: "
read -r confirm
confirmAction || exit 1

$ESCALATION_TOOL usermod -aG $groups_to_add "$username"
Expand Down
3 changes: 2 additions & 1 deletion tabs/utils/user-account-manager/change_password.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ printf "%b\n" "${YELLOW}=================${RC}"
username=$(promptUsername "" "root") || exit 1
password=$(promptPassword) || exit 1

read -p "Are you sure you want to change password for $username? [Y/N]: " confirm
printf "Are you sure you want to change password for $username? [Y/N]: "
read -r confirm
confirmAction || exit 1

echo "$username:$password" | $ESCALATION_TOOL chpasswd
Expand Down
3 changes: 2 additions & 1 deletion tabs/utils/user-account-manager/delete_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ if [ "$username" = "$USER" ]; then
return
fi

read -p "Are you sure you want to delete user $username? [Y/N]: " confirm
printf "Are you sure you want to delete user $username? [Y/N]: "
read -r confirm
confirmAction || exit 1

$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
Expand Down
3 changes: 2 additions & 1 deletion tabs/utils/user-account-manager/remove_from_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ checkGroupAvailabe "$groups" "$user_groups" || exit 1

groups_to_remove=$(echo "$groups" | tr ' ' ',')

read -p "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: " confirm
printf "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: "
read -r confirm
confirmAction || exit 1

$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
Expand Down
11 changes: 7 additions & 4 deletions tabs/utils/user-account-manager/utility_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

# Prompt for username
promptUsername() {
read -p "Enter the username: " username
printf "Enter the username: "
read -r username

checkEmpty "$username";

Expand All @@ -21,9 +22,11 @@ promptUsername() {
# Prompt for password
promptPassword() {
stty -echo
read -p "Enter the password (PASSWORD IS HIDDEN): " password1
printf "Enter the password (PASSWORD IS HIDDEN): "
read -r password1
echo >&2
read -p "Re-enter the password (PASSWORD IS HIDDEN): " password2
printf "Re-enter the password (PASSWORD IS HIDDEN): "
read -r password2
echo >&2
stty echo

Expand Down Expand Up @@ -97,4 +100,4 @@ checkGroupAvailabe() {
}

checkEnv
checkEscalationTool
checkEscalationTool
Loading