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"