Last active
August 29, 2015 14:20
-
-
Save dwurf/f7f7e63ba1a695d88db8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to install kf2 server under wine on ubuntu 14.04 (AWS micro instance) | |
# This script makes a mess, run it in a subdirectory to keep it contained | |
# Also run it on a server you don't care about or be sure you don't mind when it | |
# installs a bunch of random crap | |
# Install wine | |
if dpkg -l wine > /dev/null 2>/dev/null; then | |
echo 'wine already installed' | |
else | |
sudo dpkg --add-architecture i386 | |
sudo apt-get -y update && sudo apt-get -y upgrade | |
sudo apt-get -y install wine | |
fi | |
# Install steamcmd | |
[[ -f steamcmd.zip ]] || wget http://media.steampowered.com/installer/steamcmd.zip | |
[[ -f steamcmd.exe ]] || unzip -o steamcmd.zip | |
[[ -f KF2_WineDLL.zip ]] || wget http://www.redorchestra2.fr/downloads/KF2_WineDLL.zip | |
# Install kf2, steamcmd, dependencies | |
WINEDEBUG=fixme-all wine steamcmd.exe +exit | |
[[ -d kf2server ]] || WINEDEBUG=fixme-all wine steamcmd.exe +login anonymous +force_install_dir ./kf2server +app_update 232130 validate +exit | |
[[ -f ~/.wine/drive_c/windows/system32/msvcr100.dll ]] || (cd ~/.wine/drive_c/windows/system32; unzip -o $OLDPWD/KF2_WineDLL.zip) | |
[[ -d ~/.wine/drive_c/windows/temp/_vcrun2010 ]] || winetricks -q vcrun2010 & sleep 10 | |
# Generate INI files | |
if [[ ! -f kf2server/KFGame/Config/PCServer-KFGame.ini ]]; then | |
port=7777 | |
wine kf2server/Binaries/Win64/KFServer kf-bioticslab?difficulty=0?adminpassword=secret?gamepassword=ninja -port=$port & | |
sleep 20 | |
kfpid=$(pgrep -f port=$port) | |
kill $kfpid | |
fi | |
# Create launcher and config templates | |
cat > update_kf2 << EOF | |
#!/bin/bash | |
WINEDEBUG=fixme-all wine steamcmd.exe +login anonymous +force_install_dir ./kf2server +app_update 232130 validate +exit | |
EOF | |
cat > launch_kf2 << EOF | |
#!/bin/bash | |
# 0-normal 1-hard 2-suicidal 3-hell on earth | |
difficulty=0 | |
map="KF-BioticsLab" | |
admin_password=secret | |
game_password=ninja | |
game_port=7777 | |
web_port=9001 | |
query_port=27015 | |
#curl -s http://169.254.169.254/latest/user-data | grep '404 - Not Found' > /dev/null 2>&1 || \ | |
# curl -s http://169.254.169.254/latest/user-data > user-data | |
#source user-data | |
cmd="wine kf2server/Binaries/Win64/KFServer " | |
cmd+="\$map" | |
cmd+="?GameDifficulty=\$difficulty" | |
cmd+="?AdminPassword=\$admin_password" | |
cmd+="?GamePassword=\$game_password" | |
cmd+=" -Port=\$game_port" | |
cmd+=" -WebAdminPort=\$web_port" | |
cmd+=" -QueryPort=\$query_port" | |
echo \$cmd > \$0.log | |
exec \$cmd | |
EOF | |
chmod u+x update_kf2 | |
chmod u+x launch_kf2 | |
sudo bash -c "echo 'cd $PWD | |
sudo -u $USER ./update_kf2 | |
sudo -u $USER ./launch_kf2 | |
' > /etc/rc.local" | |
# vim:ts=4:sts=4:sw=4:et:ai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment