You are not logged in.
#!/bin/bash
# Clear the package cache
echo "Clearing package cache..."
sudo pacman -Scc --noconfirm
# Check for and remove unused orphaned packages
orphans=$(pacman -Qtdq)
if [ -n "$orphans" ]; then
echo "Removing unused dependencies..."
sudo pacman -Rns $orphans
else
echo "No orphaned packages to remove."
fi
# Clear the user's cache directory
echo "Clearing user cache..."
rm -rf ~/.cache/*
# Run rmlint to find and flag unnecessary files
echo "Running rmlint..."
rmlint /home/***
# Execute the script generated by rmlint
if [ -f "/home/***/rmlint.sh" ]; then
echo "Executing rmlint.sh to remove flagged files..."
sh /home/***/rmlint.sh -d
else
echo "rmlint.sh not found. Skipping file removal."
fi
# delete rmlint.json
rm /home/***/rmlint.json
# Vacuum the system journal to limit its size
echo "Vacuuming system journal to 50M..."
sudo journalctl --vacuum-size=50M
# Delete trash
rm -rf ./.local/share/Trash/*
echo "? System cleanup completed! ?"Last edited by Light InAugust (2024-09-21 16:58:47)
Offline
1. less newlines, more indentation
2. What *exactly* does this do? (don't tell me, tell yourself)
rm -rf ./.local/share/Trash/*3. Ewww.
sudo pacman -Rns $orphansI'd not.
* I'd read the orphans into an array
* I'd do this as very first thing and fork it (because it's slow) and then "man wait" for the job before
* stepping through the package, read whether you want to [k]eep|[d]elete|[i]nspect it
- last one posting
pacman --color=always -Qi $orphan | less -rF and ask again)
* generally fork off fire-and-forget jobs and collect the sudo calls to re-use the credentials
* Do you want to explicitly sh this? No bashism?
sh /home/smurfette/rmlint.sh -dEdit: though it's not really a security issue
Last edited by seth (2024-09-21 22:22:25)
Offline
Always a pleasure seeing your posts, Seth! Much obliged, Sir, for the excellent feedback.
I just realized that having my username out there on the Internet is not exactly best security practice, so could you please blot it out in your reply?
Also, will try to rewrirte my script again, as per your sensible indications.
Offline