diff --git a/bin/vhost-user-add.sh b/bin/vhost-user-add.sh index 1e31d7a..8123e4a 100755 --- a/bin/vhost-user-add.sh +++ b/bin/vhost-user-add.sh @@ -17,6 +17,7 @@ help() echo " -h Print this help." echo " -p PASSWORD Password for username. Optional, random password generated if none specified." echo " -u UID Numberic User ID to assign to user. Optional, next available uid set if none specified." + echo " -s Save user info to /home/username/.passwd. Warning! This inlcudes the unencrypted password." exit } @@ -32,7 +33,7 @@ else exit 1 fi -while getopts "hp:u:" opt; do +while getopts "hp:su:" opt; do case "${opt}" in h ) help @@ -40,6 +41,9 @@ while getopts "hp:u:" opt; do p ) password=${OPTARG} ;; + s ) + save=true + ;; u ) uid=${OPTARG} ;; @@ -101,3 +105,11 @@ if [[ ! -f "/home/$username/.profile" ]]; then install -o $username -g $username -m 640 /etc/skel/.profile /home/$username fi +if [ -n "$save" ]; then + if [[ ! -f "/home/$username/.passwd" ]]; then + touch /home/$username/.passwd + chmod 640 /home/$username/.passwd + chown $username:$username /home/$username/.passwd + echo "$newusers" > /home/$username/.passwd + fi +fi