Make user functions more robust
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Remove a user from the server
|
||||
# Copyright 2021 Bryan C. Roessler
|
||||
# Copyright 2021-2023 Bryan C. Roessler
|
||||
|
||||
parent="${BASH_SOURCE[0]}"
|
||||
parent=${parent%/*}
|
||||
@@ -23,15 +23,15 @@ if ! id -u "$user"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
! ask_ok "Remove user $user?" && exit $?
|
||||
ask_ok "Remove user $user?" || exit 1
|
||||
|
||||
killall -u "$user"
|
||||
|
||||
if ask_ok "Backup /home/$user?" && [[ -d /home/"$user" ]]; then
|
||||
if [[ ! -d /mnt/array/home-retired/"$user" ]]; then
|
||||
btrfs subvolume create /mnt/array/home-retired/"$user"
|
||||
if ask_ok "Backup /home/$user?" && [[ -d /home/$user ]]; then
|
||||
if [[ ! -d /mnt/array/home-retired/$user ]]; then
|
||||
btrfs subvolume create /mnt/array/home-retired/"$user" || exit 1
|
||||
fi
|
||||
rsync -av /home/"$user"/ /mnt/array/home-retired/"$user"
|
||||
rsync -av /home/"$user"/ /mnt/array/home-retired/"$user" || exit 1
|
||||
fi
|
||||
|
||||
smbpasswd -x "$user"
|
||||
|
||||
Reference in New Issue
Block a user