r1ch.net forums
* Home Help Search Login Register
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: HTTP Downloading Setup Guide (Advanced)
Pages: [1]
Print
Author Topic: HTTP Downloading Setup Guide (Advanced)  (Read 45129 times)
R1CH
Administrator
Member

Posts: 2625



« on: September 29, 2005, 12:48:32 pm »

Alright, this guide explains how to setup a content repository using Apache HTTPD. This guide assumes your repository root is in /var/www/repository and that "Options All" is available (see httpd.conf, this is usually enabled if you don't run your own HTTPD).

Make a file /var/www/repository/.htaccess with the following:
Code:
Options +MultiViews -Indexes

ForceType application/x-quake2-data
The first line turns on MultiViews and disables directory indexing. The second line sets a default mime type for all the Q2 data otherwise MultiViews does not work correctly.

Next up, fill the repository with all your raw files you want to offer, eg /var/www/repository/baseq2/maps/ztn2dm1.bsp, /var/www/repository/ctf/maps/somectfmap01.bsp, textures, sounds, whatever-  remember to place them in the appropriate gamedir that your server is also running.

Now comes the trickier bit - compressing the entire repository with gzip and changing the filenames to be multiview compatible. Luckily for you, here is a perl script that does all the hard work for you:
Code:
#!perl

use File::Find;

sub callback
{
        if ($_ =~ /\.gz$/ || $_ =~ /\..+\..+$/ || -d $_ || $_ eq '.htaccess')
        {
                return;
        }

        $file = $File::Find::name;
        print "Compressing: $file\n";

        if ($file =~ /^.+(\..+)$/)
        {
                $ext = $1;
                $unc = $file . $1;
                $com = $file . ".gz";
                system ("ls -al $file");
                unlink ($unc);
                unlink ($com);
                system ("cp -a $file $unc");
                system ("gzip -9 -n $file");
                system ("ls -al $com");
        }
}

find (\&callback, "/var/www/repository");
Run as perl updaterepository.pl (or whatever you called it), don't forget to replace the repository path (last line) if it's different. You may re-run this script every time you add a file to the repository - it won't touch already renamed/gzipped files.

Next, make sure the repository is available over HTTP somewhere, then in your R1Q2 server config, simply add set sv_downloadserver http://www.myserver.com/q2files/ or wherever the repository base URL is. That's it! R1Q2 clients (and soon hopefully many others) can now enjoy full-speed downloads without having to leave the game. The trailing / at the end of the sv_downloadserver is required!
« Last Edit: May 04, 2007, 01:58:54 pm by R1CH » Logged
spirit
Member

Posts: 8


« Reply #1 on: May 03, 2007, 03:53:17 pm »

The perl script will fail for (rare and stupid) maps that have files with special characters like '&' in their filename.
Logged
aprisobal
Member

Posts: 2


« Reply #2 on: August 01, 2007, 06:56:22 am »

Some kind of servers doesn't properly handle .gz files (i.e. Apache doesn't send Content-Encoding header). Try this:
Code: (/var/www/repository/.htaccess)
AddEncoding x-gzip gz

Options +MultiViews -Indexes

ForceType application/x-quake2-data
Logged
Rct. Tsoul
Member

Posts: 9



« Reply #3 on: September 10, 2012, 05:39:38 am »

Instructions in laments terms that actually works, this is assuming that you don't know shit.
create a .htaccess file with notepad and insert the following text into it, then save it
Code:
AddEncoding x-gzip gz

Options +MultiViews -Indexes

ForceType application/x-quake2-data
upload this file to your web server space that has your quake 2 files in it, it should be the folder that has the mod folders, baseq2, lithium, dday

next, create a file and save it with a .pl extension, and paste this code into it
Code:
#!perl

use File::Find;

sub callback
{
        if ($_ =~ /\.gz$/ || $_ =~ /\..+\..+$/ || -d $_ || $_ eq '.htaccess')
        {
                return;
        }

        $file = $File::Find::name;
        print "Compressing: $file\n";

        if ($file =~ /^.+(\..+)$/)
        {
                $ext = $1;
                $unc = $file . $1;
                $com = $file . ".gz";
                system ("ls -al $file");
                unlink ($unc);
                unlink ($com);
                system ("cp -a $file $unc");
                system ("gzip -9 -n $file");
                system ("ls -al $com");
        }
}

find (\&callback, "/var/www/repository");
make sure have the correct path of your q2 files on that last line, if you don't know what the path should be, then you should see it in FileZilla when you are viewing your q2 folder that people will download from, just copy & paste that path to replace the path in the code above.

Next upload this new file updaterepository.pl to your cgi-bin folder located under your public_html folder

Next SSH to your web space using Putty, downloadhttp://www.putty.org/
once your logged in change to the directory of your cgi-bin and type the following
Code:
chmod +x updaterepository.pl
Code:
screen -S perl
that will open a screen session that will continue if you somehow get disconnected
now to start the compression process type:
Code:
perl updaterepository.pl

Now you will see a all your files getting compressed within that directory, and now you shall be havin fast compressed downloads
Logged
Rct. Tsoul
Member

Posts: 9



« Reply #4 on: September 11, 2012, 04:50:01 am »

Crap, there is something I am forgetting, the http downloading is still not working, maybe there is certain file permissions or html document to place at the http server to allow Quake2 to get or search the files, I forgot, please help, I know I am forgetting something.
Logged
Pages: [1]
Print
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: HTTP Downloading Setup Guide (Advanced)
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines