Skip to content

Instantly share code, notes, and snippets.

@kahrl
Last active December 21, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kahrl/6351943 to your computer and use it in GitHub Desktop.
Save kahrl/6351943 to your computer and use it in GitHub Desktop.
--- collectstatic.sh 2013-08-27 12:15:00.311295847 +0200
+++ collectstatic_new.sh 2013-08-27 12:29:50.307039963 +0200
@@ -9,40 +9,40 @@
exit 1
}
-if [ ! -f $MINETESTDIR ]; then
- echo "Please specify a valid Minetest directory"
+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 || die "OpenSSL without sha1 won't work"
+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
- for f in `find $MINETESTDIR/games/$GAMENAME/mods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x"`; do
- echo `basename $f`
- cp $f $MEDIADIR/`cat $f | openssl dgst -sha1 | awk '{print $2}'`
+ 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
- for f in `find $WORLDDIR/worldmods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x"`; do
- echo `basename $f`
- cp $f $MEDIADIR/`cat $f | openssl dgst -sha1 | awk '{print $2}'`
+ 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 [ -f $MINETESTDIR/mods ]; then
- for f in `find $MINETESTDIR/mods -type f -name "*.png" -o -name "*.ogg" -o -name "*.x"`; do
- echo `basename $f`
- cp $f $MEDIADIR/`cat $f | openssl dgst -sha1 | awk '{print $2}'`
+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
-for f in `find $MEDIADIR -type f`; do
- cat $f | openssl dgst -binary -sha1 >> $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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment