Bash script to download haks and overrides
-
This bash script will download, sort, extract and lowercase all the required files to play CoA on a operation system such as like linux. You will still have to move and replace the files into your NWN installation manually.
Simply copy the script below into an empty file and run it in a terminal.
Make sure you have wget and p7zip installed or the script won't do much for you.#!/bin/bash directory="COAFILES" coaserverfile="http://216.155.133.53/forum/download/player.xml" command -v wget >/dev/null 2>&1 || { echo >&2 "The script require wget but it's not installed. Aborting."; exit 1; } command -v p7zip >/dev/null 2>&1 || { echo >&2 "The script require p7zip but it's not installed. Aborting."; exit 1; } echo "This script will download the necessary haks to play COA" echo "Answer yes to proceed" read -p "$ " ans ans="$(echo ${ans} | tr 'A-Z' 'a-z')" if [ "$ans" == "yes" ]; then if [ -d "$directory" ]; then echo "`pwd`/$directory already exists!" echo "Want to remove the directory $directory and continue?" read -p "$ " ans ans="$(echo ${ans} | tr 'A-Z' 'a-z')" if [ "$ans" == "yes" ]; then rm -rf $directory else echo "No changes has been made" exit 1 fi fi mkdir $directory cd $directory directory=`pwd` wget $coaserverfile -O TEMP.XML xmldir=(`cat "TEMP.XML" | grep '<subfolder' |="" cut="" -d="" '="">' -f 2 | cut -d '<' -f 1`) xmlurl=(`cat "TEMP.XML" | grep '<url' |="" cut="" -d="" '="">' -f 2 | cut -d '<' -f 1`) rm -f TEMP.XML for (( i=0;i!=${#xmlurl[@]};i++)); do category=${xmldir[${i}]} package=${xmlurl[${i}]} if [[ ! -d "$category" && ! -z "$category" ]]; then mkdir $category fi if [ ! -z "$category" ]; then cd $category fi wget $package -O temp.7z p7zip -d temp.7z cd $directory done rename 'y/A-Z/a-z/' * rename 'y/A-Z/a-z/' */* echo "Everything was downloaded, extracted and lowercased!" echo "Now merge the files from $directory to your NWN directory." echo "Have fun playing CoA and please leave a comment on the forum!" exit 1 else echo "No downloads started" exit 1 fi</url'></subfolder'>
Please, use the script karandil posted in this thread if you want to install, update and maintain the required files to play COA. You need xsltproc commandline tools installed but will be more efficient to use and is much faster since it will only download what you need to update. The script I made above will simply download everything all the time!
-
Well, cool? We have an auto downloader though. This is for another operating system?
-
Linux bash (command line) script, Zool.
The auto-downloader is only usable by Windows clients. -
Anyone know mac enough who could help me design one for OSX? I don't have a problem downloading it piece by piece but it would be fun to just have an auto-downloader
-
Linux bash (command line) script, Zool.
The auto-downloader is only usable by Windows clients.Was 99% certain of that.
-
@latoksinned:
Anyone know mac enough who could help me design one for OSX? I don't have a problem downloading it piece by piece but it would be fun to just have an auto-downloader
If its a *nix version of OSX you should be able to run the script provided that you have all the commands installed.
All commands except p7zip is standard linux shell commands. -
Well, I didn't quite manage to install NWN for my Ubuntu. I'll give it another try though. I just need to learn a bit more. :)
-
Its a long time since I installed it but if you need help with linux and nwn then throw me a PM
-
Thx for the script, works fine for me.
I see you hardcoded the files' URLs, which could be a hassle to maintain. Then I realized the windows downloader doesn't seem to need reinstalling when a new hak is added, which means it manages to find said list somewhere from the CoA site. Anyone has an idea of where that could be? -
We update the list ourselves, so you don't have to.
-
I think he means that while the windows downloader updates the list, this script doesn't, and it probably could be fashioned a way to use the same master-list.
-
We update the list manually. Our downloader does check file size and date modified though. But it checks it against that manually created list we make every time we update the haks.
-
Thx for the script, works fine for me.
I see you hardcoded the files' URLs, which could be a hassle to maintain. Then I realized the windows downloader doesn't seem to need reinstalling when a new hak is added, which means it manages to find said list somewhere from the CoA site. Anyone has an idea of where that could be?I'm glad the script was to use for you!
Fetching a text file from a URL is minor changes to the script. I might add it some time if I know where to find the updated list.
-
we use an XML file which we really cant give access to for various security reasons.
-
I updated the script so it should work once again with the new filenames and tlk package.
-
removed the hardcoded urls to make the script work even when changes and updates are made. The script will download everything just like the CoA windows installer does but it still only sorts overrides and haks. Everything else will be extracted into the base directory that the script creates.
-
Gave the script another touch today, possible final one.
It should work no matter what the CoA staff adds to the game now. Even new categories such as music or portraits would be downloaded, sorted and lowercased for you.Cheers!
-
For my return after a month of LARP preparations and play, I propose you another script that only downloads what you really need. It requires installing xsltproc on your Linux, using your usual package management tool. The script contains a usage message you can print out with the -h option. It works with default parameters if you run it from your NWN install directory.
#! /bin/bash listurl="http://216.155.133.53/forum/download/player.xml" xslscript=' <xsl:stylesheet xmlns:xsl="http: 1999="" www.w3.org="" xsl="" transform" version="1.0"><xsl:output method="text"><xsl:template match="file"><xsl:value-of select="url"><xsl:text>;</xsl:text> <xsl:value-of select="subfolder"><xsl:text>;</xsl:text> <xsl:value-of select="testfile"><xsl:text>;</xsl:text> <xsl:value-of select="size"><xsl:text>;</xsl:text> <xsl:value-of select="utcmodifieddate"><xsl:text>@</xsl:text> <xsl:template match=" "=""><xsl:apply-templates select=" file"="">'</xsl:apply-templates select="></xsl:template match="></xsl:value-of select="utcmodifieddate"></xsl:value-of select="size"></xsl:value-of select="testfile"></xsl:value-of select="subfolder"></xsl:value-of select="url"></xsl:template match="file"></xsl:output method="text"></xsl:stylesheet xmlns:xsl="http:> usage() { cat << EOF usage: $0 options This script updates the COA haks and overrides on your COA install. It only downloads more recent files. OPTIONS: -h Show this message -n <path> Location of the NWN install (defaults to .) -t <path> Temporary diretory where the downloads are stored (defaults to ./COAFILES) -A Download everything EOF } TMPDIR="./COAFILES" NWNDIR="." DLOAD_ALL=0 while getopts hAn:t: OPTION do case $OPTION in h) usage exit 1 ;; A) DLOAD_ALL=1 ;; n) NWNDIR=$OPTARG ;; t) TMPDIR=$OPTARG ;; ?) usage exit ;; esac done if [ ! -d ${NWNDIR}/hak -o ! -d ${NWNDIR}/override ] ; then echo "${NWNDIR}is not a nwn install directory" exit 1 fi if [ $DLOAD_ALL = 0 ] ; then WGET_OPT="-N" else WGET_OPT="-S" fi LISTFILES=`echo $xslscript | xsltproc - $listurl | tr ' ' '-' ` IFS='@' read -ra FILEINFO <<< "$LISTFILES" for info in ${FILEINFO[@]} ; do IFS=';' read -ra ONEFILE <<< "$info" TESTFILE=$NWNDIR/${ONEFILE[1]}/${ONEFILE[2]} if [ -f "$TESTFILE" ] ; then ACTUALDATE=`stat -c '%Y' $TESTFILE` ACTUALSIZE=`stat -c '%s' $TESTFILE` ACTUALUTC=`date -u +'%Y/%m/%d-%T' -d @$ACTUALDATE` else ACTUALDATE='none' ACTUALSIZE=0 ACTUALUTC='nodate' echo "Not found: $TESTFILE from $info" fi if [ ${ONEFILE[3]} != $ACTUALSIZE -a "${ONEFILE[3]}" != "$ACTUALUTC" ] ; then echo "$TESTFILE is out-of-date" wget ${ONEFILE[0]} 7z x -o$TMPDIR `basename ${ONEFILE[0]}` for file in ${TMPDIR}/* do cp -f $file ${ONEFILE[1]}/`basename $file | tr 'A-Z' 'a-z'` done rm -f `basename ${ONEFILE[0]}` ${TMPDIR}/* else echo "$TESTFILE is up-to-date" fi done
-
Just so you know, it seems that the script, even though it is using an URL with IP@, still works. I'm not sure if it really gets what it should be getting, though.
-
It's because it uses an IP, not an expired domain name, to get hold of the xml file. The auto downloader uses the domain name to look for the XML file, and so fails. The XML file is fine and points to the right stuff (because I changed it to do so)