add_new_user.sh; fix some errors.

This commit is contained in:
Christoph 2018-04-12 02:21:16 +00:00
parent c4e91648fd
commit 3a03296fa0

View File

@ -78,9 +78,11 @@ if ! id -u "${user_name}" > /dev/null 2>&1 ; then
cp -a "${skel_dir}/.profile" "${home_base_dir}/${user_name}/"
chown ${user_name}:${user_name} "${home_base_dir}/${user_name}/.profile"
fi
else
user_uid=$(id -u ${user_name})
user_gid=$(id -g ${user_name})
fi
# - Set new password
# -
if $password_needed ; then
@ -93,7 +95,7 @@ if $password_needed ; then
# - chris
# -
elif [[ "$user_name" = 'chris' ]]; then
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$5SJpnMml\\\$SKedIm8KbDoG6PPwmoq9jbg4Y5pukPp1lzq9AOgugLGSHMQo3tL6Ih/YvX295mL2svhYi4emf.xZV9t95.72d0:\2#" /etc/shadow
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$eS5Z/MP3\\\$9L5nW7lUSgKI2Sxe4tQGZYQHhndLnKh6ysOuxvQ6YGT7Q6IXihscvw.sVareOHohwjbLDbbAXHK0FWOEQYH2e1:\2#" /etc/shadow
# - root
# -
@ -108,7 +110,7 @@ if $password_needed ; then
fi
home_dir="$(cat /etc/passwd | grep ${user_name} | cut -d':' -f6)"
home_dir="$(cat /etc/passwd | grep -E "^${user_name}:" | cut -d':' -f6)"
# - Backup existing files befor replacing them..