2024-09-19 02:48:42 +01:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
. ../../common-script.sh
|
|
|
|
. ./utility_functions.sh
|
|
|
|
|
|
|
|
clear
|
|
|
|
printf "%b\n" "${YELLOW}Delete a user${RC}"
|
|
|
|
printf "%b\n" "${YELLOW}=================${RC}"
|
|
|
|
|
|
|
|
username=$(promptUsername "" "non-root") || exit 1
|
|
|
|
|
|
|
|
# Check if current user
|
|
|
|
if [ "$username" = "$USER" ]; then
|
|
|
|
printf "%b\n" "${RED}Cannot delete the current user${RC}"
|
|
|
|
printf "%b\n" "${RED}Press [Enter] to continue...${RC}"
|
|
|
|
read dummy
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2024-09-19 17:39:09 +01:00
|
|
|
printf "Are you sure you want to delete user $username? [Y/N]: "
|
|
|
|
read -r confirm
|
2024-09-19 02:48:42 +01:00
|
|
|
confirmAction || exit 1
|
|
|
|
|
|
|
|
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
|
|
|
|
printf "%b\n" "${GREEN}User $username deleted successfully${RC}"
|
|
|
|
|
|
|
|
checkEnv
|