#!/bin/sh #Options MINETESTDIR=. GAMENAME=minetest_game WORLDDIR=none MEDIADIR=./media function die { echo "$1" exit 1 } if [ ! -d $MINETESTDIR ]; then die "Please specify a valid Minetest directory" fi which openssl &> /dev/null || die "Install the OpenSSL commandline tool!" openssl -h 2>&1 | grep sha1 &> /dev/null || die "OpenSSL without sha1 won't work" which awk &> /dev/null || die "Install (g)awk!" mkdir -p $MEDIADIR if [ ! $GAMENAME == none ]; then find $MINETESTDIR/games/$GAMENAME/mods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x" | while read f; do basename "$f" cp "$f" $MEDIADIR/`cat "$f" | openssl dgst -sha1 | awk '{print $2}'` done fi if [ ! $WORLDDIR == none ]; then find $WORLDDIR/worldmods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x" | while read f; do basename "$f" cp "$f" $MEDIADIR/`cat "$f" | openssl dgst -sha1 | awk '{print $2}'` done fi if [ -d $MINETESTDIR/mods ]; then find $MINETESTDIR/mods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x" | while read f; do basename "$f" cp "$f" $MEDIADIR/`cat "$f" | openssl dgst -sha1 | awk '{print $2}'` done fi echo -n "Creating index.mth..." echo -en "MTHS\x00\x01" > $MEDIADIR/index.mth find $MEDIADIR -type f ! -name index.mth | while read f; do cat "$f" | openssl dgst -binary -sha1 >> $MEDIADIR/index.mth done echo "done"