-s option to save user info to file
This commit is contained in:
parent
6a1411bb51
commit
6606865372
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user