Skip to content

Commit

Permalink
initia
Browse files Browse the repository at this point in the history
  • Loading branch information
insanity54 committed Oct 7, 2014
1 parent c34bf2e commit 960956e
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/bf1942
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
assets/*.run
assets/*.tar.gz
assets/bf1942
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:14.04

MAINTAINER Chris Grimmett <[email protected]>

# add server assets to container
ADD ./assets /srv/assets

# satisfy some deps
RUN apt-get update && apt-get -y install wget expect

# setup battlefield server package
# * downloads needed bf server files
# * extracts 1.6 files
# * patches to 1.61
RUN bash -x /srv/assets/setup.sh

# open ports for BF server
EXPOSE 14567

# run battlefield server
# RUN bash -x /srv/assets/bf1942/start.sh #dont do this here
2 changes: 2 additions & 0 deletions assets/MD5SUMS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
af60e2a2abd3a142da248276d558d43a *bf1942_lnxded-1.6-rc2.run
7534f940c5e0db0bc0653a2b37076622 *bf1942-update-1.61.tar.gz
13 changes: 13 additions & 0 deletions assets/extract
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/expect

spawn "/home/chris/scripts/bff/assets/bf1942_lnxded-1.6-rc2.run" --keep

expect {
timeout { send_user "\ntimeout in extraction\n"; exit 1 }
eof { send_user "\nunexpected eof in extraction\n"; exit 1 }
"*ress return"
}

send "^c"

send_user "\nfinished\n"
39 changes: 39 additions & 0 deletions assets/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

serverFile='/tmp/bf1942_lnxded-1.6-rc2.run'
patchFile='/tmp/bf1942-update-1.61.tar.gz'


# verify needed files are downloaded
# download the server if it's not already downloaded
if [[ ! -e $serverFile ]]; then
echo 'downloading 1.6 server'
wget 'https://www.dropbox.com/s/dnjan96ol1t5rms/bf1942_lnxded-1.6-rc2.run?dl=0' -O $serverFile
fi

# download patch if not already downloaded
if [[ ! -e $patchFile ]]; then
echo 'downloading 1.61b patch'
wget 'https://www.dropbox.com/s/9sfg0hd8xae42r5/bf1942-update-1.61.tar.gz?dl=0' -O $patchFile
fi

# copy downloaded files in tmp dir to current dir
cp $serverFile /srv/assets
cp $patchFile /srv/assets

# verify downloaded files are valid
cd /srv/assets
md5sum -c MD5SUMS

if [[ $? -ne 0 ]]; then
echo 'downloaded file integrity check failed'
else
echo 'downloaded files are full of integrity'
fi

# extract 1.6 files
./extract

# patch to 1.61
tar -xvf ./bf1942-update-1.61.tar.gz

4 changes: 4 additions & 0 deletions assets/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# send heartbeat to the new master server (workaround for gamespy shutdown)
echo '109.71.69.254 master.gamespy.com' >> /etc/hosts
32 changes: 32 additions & 0 deletions bf1942.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# battlefield 1942 upstart script
description "start and stop battlefield 1942 server"
version "0.1"
author "Chris Grimmett <[email protected]>"

# config
env BF1942_HOME=/srv
env BF1942_PORT=145678
env BF1942_HOST=0.0.0.0
env BF1942_EXEC=$BF1942_HOME/start

# tell upstart we're creating a daemon
expect fork

# start when filesystems and network device are up,
# stop when powering down or rebooting
start on (local-filesystems and net-device-up)
stop on runlevel [!2345]

pre-start script
#cd $BF1942_HOME
#exec /usr/bin/bash $BF1942_EXEC
#emit bf1942_starting
end script


script
cd $BF1942_HOME
exec bin/bash $BF1942_EXEC $BF1942_HOST:$BF1942_PORT &
emit bf1942_running
end script

0 comments on commit 960956e

Please sign in to comment.