mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
Fix bashisms (#512)
Co-authored-by: nnyyxxxx <nnyyxxxx@users.noreply.github.com>
This commit is contained in:
parent
c3eea0dfff
commit
7bd9f8aee8
|
@ -52,7 +52,7 @@ installDriver() {
|
||||||
$ESCALATION_TOOL dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y
|
$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}"
|
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
|
if checkDriverInstallation; then
|
||||||
printf "%b\n" "${GREEN}Driver installed successfully.${RC}"
|
printf "%b\n" "${GREEN}Driver installed successfully.${RC}"
|
||||||
printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}"
|
printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}"
|
||||||
|
@ -91,4 +91,4 @@ printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free reposit
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
checkEscalationTool
|
checkEscalationTool
|
||||||
userConfirmation
|
userConfirmation
|
|
@ -54,8 +54,8 @@ encrypt_file() {
|
||||||
echo "Enter the path for the encrypted file or directory:"
|
echo "Enter the path for the encrypted file or directory:"
|
||||||
read -r OUTPUT_PATH
|
read -r OUTPUT_PATH
|
||||||
|
|
||||||
echo "Enter the encryption password:"
|
printf "Enter the encryption password: "
|
||||||
read -s -r PASSWORD
|
read -r PASSWORD
|
||||||
|
|
||||||
if [ -d "$INPUT_PATH" ]; then
|
if [ -d "$INPUT_PATH" ]; then
|
||||||
# Encrypt each file in the directory
|
# Encrypt each file in the directory
|
||||||
|
@ -99,8 +99,8 @@ decrypt_file() {
|
||||||
echo "Enter the path for the decrypted file or directory:"
|
echo "Enter the path for the decrypted file or directory:"
|
||||||
read -r OUTPUT_PATH
|
read -r OUTPUT_PATH
|
||||||
|
|
||||||
echo "Enter the decryption password:"
|
printf "Enter the decryption password: "
|
||||||
read -s -r PASSWORD
|
read -r PASSWORD
|
||||||
|
|
||||||
if [ -d "$INPUT_PATH" ]; then
|
if [ -d "$INPUT_PATH" ]; then
|
||||||
# Decrypt each file in the directory
|
# Decrypt each file in the directory
|
||||||
|
@ -145,8 +145,8 @@ main(){
|
||||||
*) echo "Invalid choice. Please try again." ;;
|
*) echo "Invalid choice. Please try again." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "Press [Enter] to continue..."
|
printf "Press [Enter] to continue..."
|
||||||
read -r
|
read -r dummy
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ checkGroupAvailabe "$groups" "$available_groups" || exit 1
|
||||||
|
|
||||||
groups_to_add=$(echo "$groups" | tr ' ' ',')
|
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
|
confirmAction || exit 1
|
||||||
|
|
||||||
$ESCALATION_TOOL usermod -aG $groups_to_add "$username"
|
$ESCALATION_TOOL usermod -aG $groups_to_add "$username"
|
||||||
|
|
|
@ -10,7 +10,8 @@ printf "%b\n" "${YELLOW}=================${RC}"
|
||||||
username=$(promptUsername "" "root") || exit 1
|
username=$(promptUsername "" "root") || exit 1
|
||||||
password=$(promptPassword) || 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
|
confirmAction || exit 1
|
||||||
|
|
||||||
echo "$username:$password" | $ESCALATION_TOOL chpasswd
|
echo "$username:$password" | $ESCALATION_TOOL chpasswd
|
||||||
|
|
|
@ -17,7 +17,8 @@ if [ "$username" = "$USER" ]; then
|
||||||
return
|
return
|
||||||
fi
|
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
|
confirmAction || exit 1
|
||||||
|
|
||||||
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
|
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
|
||||||
|
|
|
@ -20,7 +20,8 @@ checkGroupAvailabe "$groups" "$user_groups" || exit 1
|
||||||
|
|
||||||
groups_to_remove=$(echo "$groups" | tr ' ' ',')
|
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
|
confirmAction || exit 1
|
||||||
|
|
||||||
$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
|
$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
# Prompt for username
|
# Prompt for username
|
||||||
promptUsername() {
|
promptUsername() {
|
||||||
read -p "Enter the username: " username
|
printf "Enter the username: "
|
||||||
|
read -r username
|
||||||
|
|
||||||
checkEmpty "$username";
|
checkEmpty "$username";
|
||||||
|
|
||||||
|
@ -21,9 +22,11 @@ promptUsername() {
|
||||||
# Prompt for password
|
# Prompt for password
|
||||||
promptPassword() {
|
promptPassword() {
|
||||||
stty -echo
|
stty -echo
|
||||||
read -p "Enter the password (PASSWORD IS HIDDEN): " password1
|
printf "Enter the password (PASSWORD IS HIDDEN): "
|
||||||
|
read -r password1
|
||||||
echo >&2
|
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
|
echo >&2
|
||||||
stty echo
|
stty echo
|
||||||
|
|
||||||
|
@ -97,4 +100,4 @@ checkGroupAvailabe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
checkEscalationTool
|
checkEscalationTool
|
Loading…
Reference in New Issue
Block a user