Fix script-user-add
This commit is contained in:
@@ -14,13 +14,13 @@ echo "$@"
|
|||||||
|
|
||||||
useradd_cmd=("useradd" "--create-home")
|
useradd_cmd=("useradd" "--create-home")
|
||||||
|
|
||||||
restore="no"
|
|
||||||
if [[ -d /mnt/array/home-retired/"$user" ]]; then
|
|
||||||
ask_ok "Restore user $user's files from /mnt/array/home-retired/$user?" && restore="yes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ask_ok "Create user $username with password $password?" || exit $?
|
ask_ok "Create user $username with password $password?" || exit $?
|
||||||
|
|
||||||
|
restore="no"
|
||||||
|
if [[ -d /mnt/array/home-retired/"$username" ]]; then
|
||||||
|
ask_ok "Restore user $username's files from /mnt/array/home-retired/$user?" && restore="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
ask_ok "Make user $username an admin?" && \
|
ask_ok "Make user $username an admin?" && \
|
||||||
useradd_cmd+=("-G" "wheel")
|
useradd_cmd+=("-G" "wheel")
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ ask_ok "Enable shared file access for user $username?" && \
|
|||||||
"${useradd_cmd[@]}"
|
"${useradd_cmd[@]}"
|
||||||
|
|
||||||
if [[ "$restore" == "yes" ]]; then
|
if [[ "$restore" == "yes" ]]; then
|
||||||
if rsync -av --progress=info2 /mnt/array/home-retired/"$user" /home/"$user"; then
|
if rsync -av --progress=info2 /mnt/array/home-retired/"$username" /home/"$username"; then
|
||||||
ask_ok "User $user's files successfully restored, remove backup at /mnt/array/home-retired/$user?" && \
|
ask_ok "User $username's files successfully restored, remove backup at /mnt/array/home-retired/$username?" && \
|
||||||
rm -rf /mnt/array/home-retired/"$user"
|
rm -rf /mnt/array/home-retired/"$username"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -50,6 +50,6 @@ echo "$username:$start_uid:$id_num" >> /etc/subuid
|
|||||||
echo "$username:$start_gid:$id_num" >> /etc/subgid
|
echo "$username:$start_gid:$id_num" >> /etc/subgid
|
||||||
|
|
||||||
# Copy manual to user desktop
|
# Copy manual to user desktop
|
||||||
ln -s README.html /home/"$user"/Desktop/
|
ln -s README.html /home/"$username"/Desktop/
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
Reference in New Issue
Block a user