From 8d12d96bb3a24b3726fce5fac7d6dd341d23875e Mon Sep 17 00:00:00 2001 From: Douglas Barone Date: Tue, 7 Mar 2023 14:22:56 -0400 Subject: [PATCH] Add u if necessary --- pdc-del-user.sh | 6 ++++++ pdc-reset-password.sh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/pdc-del-user.sh b/pdc-del-user.sh index 373fb6b..7ba7368 100755 --- a/pdc-del-user.sh +++ b/pdc-del-user.sh @@ -8,6 +8,12 @@ if [ -z "$USERNAME" ]; then exit 1 fi +# Check if $USERNAME starts with a number +if [[ $USERNAME =~ ^[0-9] ]]; then + echo "Username cannot start with a number. Appending 'u' to the beginning of the username..." + USERNAME="u$USERNAME" +fi + # Check if user exists if ! samba-tool user show $USERNAME >/dev/null 2>&1; then echo "User $USERNAME does not exist" diff --git a/pdc-reset-password.sh b/pdc-reset-password.sh index 33b572b..ae2b103 100755 --- a/pdc-reset-password.sh +++ b/pdc-reset-password.sh @@ -10,6 +10,12 @@ if [ -z "$USERNAME" ]; then exit 1 fi +# Check if $USERNAME starts with a number +if [[ $USERNAME =~ ^[0-9] ]]; then + echo "Username cannot start with a number. Appending 'u' to the beginning of the username..." + USERNAME="u$USERNAME" +fi + # Check if $USERNAME exists if ! samba-tool user show $USERNAME >/dev/null 2>&1; then echo "User $USERNAME do not exists"