Skip to content

Instantly share code, notes, and snippets.

@JayWood
Created October 3, 2015 21:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayWood/bc391429fa85f4cd2080 to your computer and use it in GitHub Desktop.
Save JayWood/bc391429fa85f4cd2080 to your computer and use it in GitHub Desktop.
Dimension cleanup script for Minecraft
#!/bin/bash
# Minecraft Dimension Management Script
# Author: Jay Wood
# URL: http://plugish.com
# License: GPLv2
# The intent of this script is to provide server owners the ability to
# generate a list of old files on their server such as extra dimensions
# so they can be deleted at a later date.
# Uncomment the below variable if you want to pre-set your server directory
MC_DIR="/home/agedcraft/multicraft/servers/server4/"
# Uncomment to tell the script to either delete, or report the files
#R_OR_D="Delete"
EMAIL_ADDR="youremail@mail.net"
report() {
if [ "$1" == "" ]; then
echo "ERROR: No param for report method."
exit 1
fi
printf '%s\n' $1 | mailx -s "Dimension Report" $EMAIL_ADDR
}
delete() {
if [ "$1" == "" ]; then
echo "ERROR: No param for delete method."
exit 1
fi
rm -vR $1
}
if [ -z "$MC_DIR" ]; then
clear
echo "Where is your minecraft root directory? Hit [ENTER] when complete:"
read MC_DIR
fi
if [ -z "$MC_DIR" ]; then
echo "You MUST have a directory, exiting."
exit 1
fi
DIR_FILES=$(find ${MC_DIR}world/* -maxdepth 0 -type d -name 'DIM*' -mtime +30)
if [ -z "$R_OR_D"]; then
PS3="What would you like to do with the results: "
OPTIONS="Report Delete"
select options in $OPTIONS; do
case $options in
Report)
report "$DIR_FILES"
exit 0
;;
Delete)
delete "$DIR_FILES"
exit 0
;;
*)
echo "Error: Please try again"
exit 1
esac
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment