From 3a03296fa06207b2feeaf764f59a8ba4004bd38c Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 12 Apr 2018 02:21:16 +0000 Subject: [PATCH] add_new_user.sh; fix some errors. --- add_new_user.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/add_new_user.sh b/add_new_user.sh index dc433e2..c897779 100755 --- a/add_new_user.sh +++ b/add_new_user.sh @@ -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..