Author Topic: Automatically Install New Maps (linux)  (Read 4086 times)

Nosfore

  • Posts: 116
  • Turrets: +0/-0
Automatically Install New Maps (linux)
« 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:

Code: [Select]
#!/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.

DASPRiD

  • Administrator
  • Posts: 549
  • Turrets: +21/-2
    • http://www.dasprids.de
Automatically Install New Maps (linux)
« Reply #1 on: January 14, 2007, 01:17:40 am »
Thank you for your work. Anyway, there are still several scripts out there, mostly many one-liners.
url=https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mail%40dasprids%2ede&item_name=DASPRiD%27s&no_shipping=0&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8][/url]

Odin

  • Spam Killer
  • *
  • Posts: 1767
  • Turrets: +113/-204
    • My Website
Automatically Install New Maps (linux)
« Reply #2 on: January 14, 2007, 02:35:06 am »
wget -r?

Mispeled

  • Posts: 148
  • Turrets: +0/-0
Automatically Install New Maps (linux)
« Reply #3 on: January 14, 2007, 03:33:46 am »
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.

Somethief

  • Posts: 284
  • Turrets: +1/-1
    • http://www.somethief.net/
Automatically Install New Maps (linux)
« Reply #4 on: January 14, 2007, 12:27:08 pm »
Quote from: "Mispeled"
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
url=http://fi.tremulous.net/]Tremulous Suomi[/url]
My blog

Nosfore

  • Posts: 116
  • Turrets: +0/-0
Automatically Install New Maps (linux)
« Reply #5 on: January 14, 2007, 05:08:52 pm »
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?

Smokey

  • Posts: 793
  • Turrets: +23/-58
    • Zilla Clan
Automatically Install New Maps (linux)
« Reply #6 on: January 14, 2007, 05:53:14 pm »
Code: [Select]
#! /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

Somethief

  • Posts: 284
  • Turrets: +1/-1
    • http://www.somethief.net/
Automatically Install New Maps (linux)
« Reply #7 on: January 15, 2007, 02:32:18 pm »
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.
url=http://fi.tremulous.net/]Tremulous Suomi[/url]
My blog

durand

  • Posts: 201
  • Turrets: +0/-0
Automatically Install New Maps (linux)
« Reply #8 on: January 15, 2007, 05:39:45 pm »
i heard on one of the posts that u can...

Somethief

  • Posts: 284
  • Turrets: +1/-1
    • http://www.somethief.net/
Automatically Install New Maps (linux)
« Reply #9 on: January 15, 2007, 06:36:41 pm »
Quote from: "durand"
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 is saying not to use them
url=http://fi.tremulous.net/]Tremulous Suomi[/url]
My blog

Nosfore

  • Posts: 116
  • Turrets: +0/-0
Automatically Install New Maps (linux)
« Reply #10 on: January 17, 2007, 11:38:43 pm »
Quote from: "Somethief"
Quote from: "durand"
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 is saying not to use them


Point taken.

I removed the URL from the post.