Add Solus utility scripts for safe user removal, checking sof-bin directories, checking what provides

This commit is contained in:
Tracey Clark 2025-05-17 20:48:53 -05:00
commit 645fa61ba4
3 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Create a backup of a user and remove them
# Must be run with sudo or as root
##Check if the user exists using getent command
user_exists=$(getent passwd $1)
#If the user doesn't exist, we need not perform the backup, just exit.
if [ -z "$user_exists" ]
then
echo "User '$1' does not exist"
else
echo "Creating backup of home dir for '$1'"
mkdir -p "/root/deleted_users"
tar czvf /root/deleted_users/"$1".tar.gz /home/"$1"
userdel -rf "$1"
echo "Removed user '$1'"
fi