Tremulous Forum
General => General Discussion => Topic started by: Nosfore on January 14, 2007, 01:05:01 am
-
Today I was faced with the task of installing all the new Tremulous Maps. I thought it was pain in the neck to do it manually, so I wrote a bash script that does it automatically.
Then I said to myself, why not share it with you folks. Here it is:
#!/bin/bash
cd
mkdir tremulous-maps
cd tremulous-maps
wget http://xxxxxxxxxx/map-sedna-beta3.zip
wget http://xxxxxxxxxx/map-utcsb2.zip
wget http://xxxxxxxxxx/map-gloom_b1.zip
wget http://xxxxxxxxxx/map-thermal-b1.zip
wget http://xxxxxxxxxx/marsbase.zip
wget http://xxxxxxxxxx/map-derelictb-beta03.zip
wget http://xxxxxxxxxx/map-dark-beta1.zip
wget http://xxxxxxxxxx/map-gloom2beta2.zip
wget http://xxxxxxxxxx/map-marsbase_b2.zip
wget http://xxxxxxxxxx/map-atcszalpha.zip
wget http://xxxxxxxxxx/map-procyon-beta2.zip
wget http://xxxxxxxxxx/map-pulse-beta3.zip
wget http://xxxxxxxxxx/map-procyon-beta1.zip
wget http://xxxxxxxxxx/map-omega_b1.zip
wget http://xxxxxxxxxx/map-hamunaptra.zip
wget http://xxxxxxxxxx/map-battlezone.zip
wget http://xxxxxxxxxx/map-procyon-preview2.zip
wget http://xxxxxxxxxx/map-derelictb-beta04.zip
wget http://xxxxxxxxxx/map-atcszalpha-b1.zip
wget http://xxxxxxxxxx/map-meep_b2.zip
wget http://xxxxxxxxxx/map-gloom3t.zip
wget http://xxxxxxxxxx/map_powergrid_b25.zip
for File in *.zip
do
unzip $File
done
for File in *.pk3
do
mv $File ~/.tremulous/base/
done
cd
rm -rf tremulous-maps
Edited: Removed possibly problematic URL from the script.
-
Thank you for your work. Anyway, there are still several scripts out there, mostly many one-liners.
-
wget -r?
-
Just out of curiosity, what server is 70.87.113.84? It gives me an error message when I go to it, but I can download those maps fine.
-
Just out of curiosity, what server is 70.87.113.84? It gives me an error message when I go to it, but I can download those maps fine.
http://nwtools.com/default.asp?prog=express&host=70.87.113.84
Looks like some actual server hoster
-
The server is one of the mirrors from tremulous.info download page. It happens to be the fastest for me.
I'm not certain that a recursive wget is such a good idea. There is more than just maps on this server. I would prefer saving their bandwith.
There was some discussion about a debian meta-package to download the maps some time ago. Anybody heard news of this?
-
#! /bin/bash
init() {
HOST="http://tremmap.omgwtf.nl/"
LIST="tremmapdownload1.php"
HOMEPATH="$HOME/.tremulous/base/"
#BASEPATH=""
if [ ! $BASEPATH ]; then # set BASEPATH above to override
BASEPATH=`which tremulous 2>/dev/null`;
if [ -L "$BASEPATH" ]; then # symlink
BASEPATH=`stat -c %N $BASEPATH \
|sed 's/.*-> \`\(.*\)\/[^/]\+/\1\/base\//'`;
elif [ -x "$BASEPATH" ]; then # file, just get the path
BASEPATH=`echo $BASEPATH |sed 's/\/[^/]\+$/\/base\//'`;
else
echo "WARNING! Cannot locate Tremulous! Set BASEPATH manually.";
fi;
fi;
if [ $UID -eq 0 ]; then # root installs to BASEPATH
if [ ! $BASEPATH ]; then
echo "Error: Set BASEPATH before running as root.";
exit 1;
fi;
cd $BASEPATH;
else # everybody else to his/her home directory
cd $HOMEPATH;
fi;
FILES=`wget $HOST$LIST -q -O - |sed 's/\r//g' |tail -n +4 |xargs -n3 \
|sed 's/[[:blank:]]/:/g'`; # get maplist
if [ ! "$FILES" ]; then
echo "Error: Could not receive maplist.";
exit 1;
fi;
}
checksum() {
if [ ! "$MD5SUM" ]; then MD5SUM=`which md5sum 2>/dev/null`; fi
if [ ! "$SHA1SUM" ]; then SHA1SUM=`which sha1sum 2>/dev/null`; fi
if [ ! "$MD5SUM$SHA1SUM" ]; then
echo "WARNING: No checksum tools found. Install md5sum or sha1sum.";
return 0;
fi;
if [ -x $MD5SUM ]; then # md5sum
echo $1 | sed 's/^\(.*\)[[:blank:]]\+\([[:alnum:]]\+\)[[:blank:]]\+\([[:alnum:]]\+\)$/\2 \1/' \
| $MD5SUM -c --status
if [ $? -ne 0 ]; then
return 1; # failed
fi;
fi;
if [ -x $SHA1SUM ]; then # sha1sum
echo $1 | sed 's/^\(.*\)[[:blank:]]\+\([[:alnum:]]\+\)[[:blank:]]\+\([[:alnum:]]\+\)$/\3 \1/' \
| $SHA1SUM -c --status
if [ $? -ne 0 ]; then
return 1; # failed
fi;
fi;
return 0; # passed
}
getfname() {
echo $1 |sed 's/[[:blank:]]\+[[:alnum:]]\+[[:blank:]]\+[[:alnum:]]\+$//';
}
verifyfile() {
if [ ! "$FILES" ]; then init; fi
fname=`getfname $1`;
if [ -f "$fname" ] && checksum "$1"; then
return 0; # local checksum passed
fi
if [ $UID -ne 0 ] && [ "$BASEPATH" ] && [ -f "$BASEPATH$fname" ]; then
if checksum "$BASEPATH$1"; then
return 0; # BASEPATH checksum passed
fi
fi
return 1; # failed or missing
}
verify() {
if [ ! "$FILES" ]; then init; fi
ok=0;
broken=0;
missing=0;
for line in $FILES; do
line=`echo $line |sed 's/:/ /g'`;
fname=`getfname $line`;
if [ -f "$fname" ] || [ -f "$BASEPATH$fname" ]; then
echo -n "$fname ";
if verifyfile "$line"; then # file exists, checksum
let ok++;
echo "OK";
else # failed
let broken++;
echo "KO";
fi
else # file missing
let missing++;
echo "$fname not found";
fi
done
echo "$broken maps broken, $missing maps missing, $ok maps OK"
}
instmaps() {
if [ ! "$FILES" ]; then init; fi
broken=0;
for line in $FILES; do
line=`echo $line |sed 's/:/ /g'`;
fname=`getfname $line`;
if [ "$1" ] && [ ! "`echo $fname |grep $1`" ]; then
continue; # masked, skip
elif verifyfile "$line"; then # already installed, skip
echo "$fname OK, skipping...";
continue;
fi
wget -c "$HOST$fname"; # download
if verifyfile "$line"; then # checksum
echo "$fname OK";
else # failed
echo "$fname has been corrupted during download, removing...";
let broken++;
rm -f $fname; # remove to allow download next time
fi
done
if [ $broken -ne 0 ]; then # status
echo "$broken maps failed to download, please rerun this script.";
else
echo "Installation successful.";
fi;
}
listmaps() {
if [ ! "$FILES" ]; then init; fi
for line in $FILES; do
line=`echo $line |sed 's/:/ /g'`;
fname=`getfname $line`;
if [ "$1" ] && [ ! "`echo $fname |grep $1`" ]; then
continue; # masked, skip
else
echo "$fname"; # print filename
fi
done
}
case "$1" in
verify)
verify;;
list)
listmaps "$2" |sort;;
license)
echo "This program is free software. It is available under the";
echo "terms of the GNU General Public License. If you did not";
echo "receive a copy of the GNU GPL with this program, you can";
echo "get on online at http://www.gnu.org/copyleft/gpl.html";;
help)
echo "$0 [install [PATTERN] | verify | list [PATTERN] | license | help]";
echo "PATTERN is any regular expression, default action is install";;
install|*)
instmaps "$2";;
esac
From the old thread...don't remember who made it.
This whole subject is really old though, there is a huge thread about it. Th
-
Yeah, http://tremulous.net/phpBB2/viewtopic.php?t=1669 . Just start reading ;)
And tremulous.info has previously told not to use their mirrors for these scripts.
-
i heard on one of the posts that u can...
-
i heard on one of the posts that u can...
I haven't seen any saying so but i might be wrong thru.
This one (http://tremulous.net/phpBB2/viewtopic.php?t=1685) is saying not to use them
-
i heard on one of the posts that u can...
I haven't seen any saying so but i might be wrong thru.
This one (http://tremulous.net/phpBB2/viewtopic.php?t=1685) is saying not to use them
Point taken.
I removed the URL from the post.