Add Solus utility scripts for safe user removal, checking sof-bin directories, checking what provides
This commit is contained in:
parent
444e1f0fc1
commit
645fa61ba4
3 changed files with 39 additions and 0 deletions
18
solus_utility/safe_remuser.sh
Normal file
18
solus_utility/safe_remuser.sh
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue