expaned username creation options
This commit is contained in:
parent
6606865372
commit
90a9d0b23c
|
@ -15,7 +15,7 @@ help()
|
|||
echo "usage: $thisfilename virtualhost [OPTIONS]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -u USERNAME Username to use for this virtualhost. Optional, defaults to first 8 characters of virtualhost."
|
||||
echo " -u USERNAME Username to use for this virtualhost. Optional, defaults to first 8 alphanumeric characters of virtualhost."
|
||||
echo " -p PASSWORD Password for username. Optional, random password generated if none specified."
|
||||
echo " -j Whether or not to jail the user. Optional, default is to not jail user."
|
||||
exit
|
||||
|
@ -27,6 +27,7 @@ if [ -n "$1" ]; then
|
|||
help
|
||||
elif vhost::validate_domain $1; then
|
||||
virtualhost="${1,,}"
|
||||
shift
|
||||
else
|
||||
echo "ERROR: Invalid virtualhost: $1"
|
||||
exit 1
|
||||
|
@ -75,6 +76,45 @@ fi
|
|||
if [ ! -n "$username" ]; then
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:8}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:7}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:6}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:5}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:9}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:10}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:11}`
|
||||
if grep -q "^$username:" /etc/passwd; then
|
||||
# username already exists, try another
|
||||
username=`echo $virtualhost | sed 's|\.||'`
|
||||
username=`echo ${username:0:12}`
|
||||
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
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! grep -q "^$username:" /etc/passwd; then
|
||||
|
|
Loading…
Reference in New Issue
Block a user