Created
June 10, 2015 17:51
-
-
Save Calinou/e0e6c759e645ed4fa624 to your computer and use it in GitHub Desktop.
Bash script to prune inactive Minetest accounts from a server (script by VanessaE)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /home/minetest/.minetest/worlds/ | |
for j in $(ls); do | |
echo /home/minetest/.minetest/worlds/$j | |
cd /home/minetest/.minetest/worlds/$j | |
rm -rf players-tmp | |
mv players players-tmp | |
mkdir players | |
chown minetest:minetest players | |
for i in $(cat auth.txt|grep ",interact" ); do | |
f=$(echo $i|cut -f 1 -d ":") | |
if [ -e "players-tmp/$f" ] ; then | |
mv players-tmp/$f players | |
fi | |
done | |
echo -n "Number of good player folders: " | |
ls players|wc|tr -s " " |cut -f 2 -d " " | |
echo -n "Number of dead, deleted player folders: " | |
ls players-tmp|wc|tr -s " " |cut -f 2 -d " " | |
# Delete dead accounts | |
n=$(cat auth.txt|wc|tr -s " " |cut -f 2 -d " ") | |
grep ",interact" auth.txt >auth.txt2 | |
n2=$(cat auth.txt2|wc|tr -s " " |cut -f 2 -d " ") | |
echo "Number of live entries in auth.txt: "$n2 | |
echo "Number of dead entries: "$((n-n2)) | |
mv auth.txt2 auth.txt | |
chown minetest:minetest auth.txt | |
rm -rf players-tmp | |
cd /home/minetest/.minetest/worlds | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment