diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 0fce5c4..8ea283d 100755 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -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|-||'` @@ -64,8 +64,19 @@ if [[ -z "$username" ]]; then # username already exists, try another username=`echo ${strippeddomain:0:12}` if grep -q "^$username:" /etc/passwd; then - echo "trouble setting unique username, specify '-u USERNAME' to use an existing username" - exit 1 + # 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 + fi + fi + fi fi fi fi