username can be between 3 and 12 characters
This commit is contained in:
parent
e4e4d4e47a
commit
c463be70a2
|
@ -37,7 +37,7 @@ if [[ -d /srv/www/$domain ]] || [[ -f /etc/apache2/sites-available/$domain.conf
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# check for and set username
|
||||
# check for and set username (length between 3 and 12 characters)
|
||||
if [[ -z "$username" ]]; then
|
||||
strippeddomain=`echo $domain | sed 's|\.||'`
|
||||
strippeddomain=`echo $strippeddomain | sed 's|-||'`
|
||||
|
@ -63,6 +63,14 @@ if [[ -z "$username" ]]; then
|
|||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo ${strippeddomain:0:12}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo ${strippeddomain:0:4}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo ${strippeddomain:0:3}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
echo "trouble setting unique username, specify '-u USERNAME' to use an existing username"
|
||||
exit 1
|
||||
|
@ -74,6 +82,9 @@ if [[ -z "$username" ]]; then
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! grep -q "^$username:" /etc/passwd; then
|
||||
|
|
Loading…
Reference in New Issue
Block a user