Update create/delete scripts, add rename script
rename user script added: renames user, home dir and connected files. delete script fix with remove of not needed options (-g) Update all scripts to exit only after all errors are shown, unless it is a critical run error.
This commit is contained in:
@@ -12,13 +12,9 @@
|
||||
# This will permaently remove the user
|
||||
|
||||
TEST=0; # do not run any actions
|
||||
GO=1; # without this flag the script will exit with an info box
|
||||
BACKUP=1;
|
||||
while getopts ":tih:" opt; do
|
||||
while getopts ":tb" opt; do
|
||||
case "${opt}" in
|
||||
g|go)
|
||||
GO=1;
|
||||
;;
|
||||
t|test)
|
||||
TEST=1;
|
||||
;;
|
||||
@@ -53,7 +49,7 @@ fi;
|
||||
# check tar, bzip2 is installed if backup = 1
|
||||
|
||||
host=$(hostname);
|
||||
timestamp=$(date +%Y%m%d-%H%M%S)
|
||||
timestamp=$(date +%Y%m%d-%H%M%S);
|
||||
# character to set getween info blocks
|
||||
separator="#";
|
||||
# base folder for all data
|
||||
@@ -92,6 +88,7 @@ fi;
|
||||
|
||||
# $1 ... $n
|
||||
for username in "$@"; do
|
||||
error=0;
|
||||
# skip if there is an option hidden
|
||||
if [[ ${_arg:0:1} = "-" ]]; then
|
||||
continue;
|
||||
@@ -108,18 +105,18 @@ for username in "$@"; do
|
||||
if ! id "${username}" &>/dev/null; then
|
||||
# not in passwd
|
||||
echo "[!!!] User ${username} does not exist in /etc/passwd";
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
break;
|
||||
fi;
|
||||
error=1;
|
||||
fi;
|
||||
user_list_entry=$(grep "${username}" "${user_list_file}");
|
||||
if [ -z "${user_list_entry}" ]; then
|
||||
echo "[!!!] User ${username} does not exist in user_list.txt file";
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
break;
|
||||
fi;
|
||||
error=1;
|
||||
elif [[ "${user_list_entry}" =~ ^#DELETED ]]; then
|
||||
echo "[!!!] User ${username} is flagged as deleted in user_list.txt file";
|
||||
error=1;
|
||||
fi;
|
||||
|
||||
if [ $error -eq 1 ]; then
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
break;
|
||||
fi;
|
||||
|
||||
Reference in New Issue
Block a user