Add u if necessary

This commit is contained in:
Douglas Barone 2023-03-07 14:22:56 -04:00
parent 53bc27a6f4
commit 8d12d96bb3
2 changed files with 12 additions and 0 deletions

View File

@ -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"

View File

@ -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"