Skip to content

Commit

Permalink
Add bf2 server and traefik in docker-compose.yml for full stack in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Nov 10, 2023
1 parent a8d111b commit 889768a
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 2 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,33 @@ See [here](docs/upgrading-docker-images-to-3.3.md).
## Development

```sh
# Start
# 1. Start BF2 server, Gamespy server, and bf2stats ASP
docker-compose up --build
# ASP available at http://localhost:8081/ASP. Username: admin, password admin. See ./config/ASP/config.php
# phpmyadmin available at http://localhost:8083. Username: root, password: ascent. See ./config/ASP/config.php config file

# 2. Once everything has started, restart the BF2 server to ensure begin recording stats
docker-compose restart bf2

# 3. Before launching the BF2 client, spoof gamespy DNS by adding these entries in C:\Windows\system32\drivers\etc\hosts. This is needed for the BF2 client to work correctly.
# Replace '192.168.1.100' with your development machine's IP address
192.168.1.100 battlefield2.available.gamespy.com
192.168.1.100 battlefield2.master.gamespy.com
192.168.1.100 battlefield2.ms14.gamespy.com
192.168.1.100 master.gamespy.com
192.168.1.100 motd.gamespy.com
192.168.1.100 gpsp.gamespy.com
192.168.1.100 gpcm.gamespy.com
192.168.1.100 gamespy.com
192.168.1.100 bf2web.gamespy.com
192.168.1.100 gamestats.gamespy.com
192.168.1.100 eapusher.dice.se

# 4. Launch BF2 client and connect to the BF2 server
# - To use BF2Hub as the Gamespy server, launch BF2.exe, and login to your BF2Hub account, and connect to the BF2 server using MULTIPLAYER > CONNECT TO IP
# - To use PRMasterserver in docker-compose as the Gamespy server, if you have previously patched BF2.exe using the BF2Hub patcher, you must unpatch BF2.exe. Then launch BF2.exe (do not use BF2Hub), create a new Online account, login, and connect to the BF2 server using MULTIPLAYER > CONNECT TO IP.
# At the end of a round, the BF2 server will send a stats snapshot to the ASP. View stats in ASP and bf2sclone.

# Development - Install vscode extensions
# Once installed, set breakpoints in code, and press F5 to start debugging.
code --install-extension bmewburn.vscode-intelephense-client # PHP intellisense
Expand All @@ -35,6 +57,18 @@ code --install-extension ms-python.python # Python intellisense
# Execute this to allow php to reach the host machine via the docker0 bridge
sudo iptables -A INPUT -i br+ -j ACCEPT

# BF2 server - Restart server
docker-compose restart bf2
# BF2 server - Attach to the bf2 server console
docker attach $( docker-compose ps -q bf2 )
# BF2 server - Exec into container
docker exec -it $( docker-compose ps -q bf2) bash
# BF2 server - Read python logs
docker exec -it $( docker-compose ps -q bf2 ) bash -c 'cat python/bf2/logs/bf2game_*'
# BF2 server - List snapshots
docker exec -it $( docker-compose ps -q bf2 ) bash -c 'ls -al python/bf2/logs/snapshots/sent'
docker exec -it $( docker-compose ps -q bf2 ) bash -c 'ls -al python/bf2/logs/snapshots/unsent'

# asp - Exec into container
docker exec -it $( docker-compose ps -q asp ) sh
# asp - List backups
Expand All @@ -58,7 +92,7 @@ docker exec $( docker-compose ps -q db ) mysqldump -uroot -pascent bf2stats | gz
# Restore the DB
zcat bf2stats.sql.gz | docker exec -i $( docker-compose ps -q db ) mysql -uroot -pascent bf2stats

# Stop
# Stop BF2 server, gamespy server and bf2stats
docker-compose down

# Cleanup
Expand Down
21 changes: 21 additions & 0 deletions config/bf2/mods/bf2/ai/aidefault-custom.ai
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
echo *****************************************************************************************
echo AIDefault.ai ****************************************************************************
echo *****************************************************************************************

aiSettings.setNSides 2
aiSettings.setAutoSpawnBots 1

rem Let's go with 63 bots! Hope your system holds up
aiSettings.overrideMenuSettings 1
aiSettings.setMaxNBots 63
aiSettings.maxBotsIncludeHumans 0
aiSettings.setBotSkill 1.0

run BotNames.ai

aiSettings.setInformationGridDimension 32


run AIPathFinding.ai

rem EOF
24 changes: 24 additions & 0 deletions config/bf2/mods/bf2/settings/maplist-custom-coop.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; mods/bf2 coop
maplist.append dalian_plant gpm_coop 16
maplist.append daqing_oilfields gpm_coop 16
maplist.append dragon_valley gpm_coop 16
maplist.append fushe_pass gpm_coop 16
maplist.append greatwall gpm_coop 16
maplist.append gulf_of_oman gpm_coop 16
maplist.append midnight_sun gpm_coop 16
maplist.append operation_clean_sweep gpm_coop 16
maplist.append operationharvest gpm_coop 16
maplist.append operationroadrage gpm_coop 16
maplist.append operationsmokescreen gpm_coop 16
maplist.append road_to_jalalabad gpm_coop 16
maplist.append sharqi_peninsula gpm_coop 16
maplist.append songhua_stalemate gpm_coop 16
maplist.append taraba_quarry gpm_coop 16
maplist.append zatar_wetlands gpm_coop 16

; mods/xpack coop
maplist.append ghost_town gpm_coop 16
maplist.append mass_destruction gpm_coop 16
maplist.append night_flight gpm_coop 16
maplist.append surge gpm_coop 16
maplist.append warlord gpm_coop 16
82 changes: 82 additions & 0 deletions config/bf2/mods/bf2/settings/maplist-custom-cq.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
; mods/bf2 conquest
maplist.append dalian_plant gpm_cq 16
maplist.append dalian_plant gpm_cq 32
maplist.append dalian_plant gpm_cq 64
maplist.append daqing_oilfields gpm_cq 16
maplist.append daqing_oilfields gpm_cq 32
maplist.append daqing_oilfields gpm_cq 64
maplist.append dragon_valley gpm_cq 128
maplist.append dragon_valley gpm_cq 16
maplist.append dragon_valley gpm_cq 32
maplist.append dragon_valley gpm_cq 64
maplist.append fushe_pass gpm_cq 16
maplist.append fushe_pass gpm_cq 32
maplist.append fushe_pass gpm_cq 64
maplist.append greatwall gpm_cq 16
maplist.append greatwall gpm_cq 32
maplist.append gulf_of_oman gpm_cq 16
maplist.append gulf_of_oman gpm_cq 32
maplist.append gulf_of_oman gpm_cq 64
maplist.append highway_tampa gpm_cq 128
maplist.append highway_tampa gpm_cq 16
maplist.append highway_tampa gpm_cq 32
maplist.append highway_tampa gpm_cq 64
maplist.append highway_tampa gpm_cq 8
maplist.append mashtuur_city gpm_cq 16
maplist.append mashtuur_city gpm_cq 32
maplist.append mashtuur_city gpm_cq 64
maplist.append midnight_sun gpm_cq 16
maplist.append midnight_sun gpm_cq 32
maplist.append midnight_sun gpm_cq 64
maplist.append operation_blue_pearl gpm_cq 16
maplist.append operation_blue_pearl gpm_cq 32
maplist.append operation_blue_pearl gpm_cq 64
maplist.append operation_clean_sweep gpm_cq 16
maplist.append operation_clean_sweep gpm_cq 32
maplist.append operation_clean_sweep gpm_cq 64
maplist.append operationharvest gpm_cq 16
maplist.append operationharvest gpm_cq 32
maplist.append operationharvest gpm_cq 64
maplist.append operationroadrage gpm_cq 16
maplist.append operationroadrage gpm_cq 32
maplist.append operationroadrage gpm_cq 64
maplist.append operationsmokescreen gpm_cq 16
maplist.append operationsmokescreen gpm_cq 32
maplist.append road_to_jalalabad gpm_cq 16
maplist.append road_to_jalalabad gpm_cq 32
maplist.append road_to_jalalabad gpm_cq 64
maplist.append sharqi_peninsula gpm_cq 16
maplist.append sharqi_peninsula gpm_cq 32
maplist.append sharqi_peninsula gpm_cq 64
maplist.append songhua_stalemate gpm_cq 16
maplist.append songhua_stalemate gpm_cq 32
maplist.append songhua_stalemate gpm_cq 64
maplist.append taraba_quarry gpm_cq 16
maplist.append taraba_quarry gpm_cq 32
maplist.append wake_island_2007 gpm_cq 64
maplist.append zatar_wetlands gpm_cq 16
maplist.append zatar_wetlands gpm_cq 32
maplist.append zatar_wetlands gpm_cq 64

; mods/xpack cq
maplist.append ghost_town gpm_cq 16
maplist.append ghost_town gpm_cq 32
maplist.append ghost_town gpm_cq 64
maplist.append iron_gator gpm_cq 16
maplist.append iron_gator gpm_cq 32
maplist.append iron_gator gpm_cq 64
maplist.append leviathan gpm_cq 16
maplist.append leviathan gpm_cq 32
maplist.append leviathan gpm_cq 64
maplist.append mass_destruction gpm_cq 16
maplist.append mass_destruction gpm_cq 32
maplist.append mass_destruction gpm_cq 64
maplist.append night_flight gpm_cq 16
maplist.append night_flight gpm_cq 32
maplist.append night_flight gpm_cq 64
maplist.append surge gpm_cq 16
maplist.append surge gpm_cq 32
maplist.append surge gpm_cq 64
maplist.append warlord gpm_cq 16
maplist.append warlord gpm_cq 32
maplist.append warlord gpm_cq 64
68 changes: 68 additions & 0 deletions config/bf2/mods/bf2/settings/serversettings-custom.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
sv.serverName "Default Server Name"
sv.password ""
sv.internet 1
sv.serverIP ""
sv.serverPort 16567
sv.welcomeMessage ""
sv.punkBuster 1
sv.allowFreeCam 1
sv.allowExternalViews 1
sv.allowNoseCam 1
sv.hitIndicator 1
sv.maxPlayers 64
sv.numPlayersNeededToStart 0
sv.notEnoughPlayersRestartDelay 15
sv.startDelay 15
sv.endDelay 15
sv.spawnTime 15
sv.manDownTime 15
sv.endOfRoundDelay 15
sv.ticketRatio 100
sv.roundsPerMap 3
sv.timeLimit 0
sv.scoreLimit 0
sv.soldierFriendlyFire 100
sv.vehicleFriendlyFire 100
sv.soldierSplashFriendlyFire 100
sv.vehicleSplashFriendlyFire 100
sv.tkPunishEnabled 1
sv.tkNumPunishToKick 3
sv.tkPunishByDefault 0
sv.votingEnabled 1
sv.voteTime 15
sv.minPlayersForVoting 1
sv.teamVoteOnly 1
sv.gameSpyPort 29900
sv.allowNATNegotiation 0
sv.interfaceIP ""
sv.autoRecord 0
sv.demoIndexURL http://
sv.demoDownloadURL http://
sv.autoDemoHook "adminutils/demo/rotate_demo.py"
sv.demoQuality 1
sv.adminScript "default"
sv.timeBeforeRestartMap 30
sv.autoBalanceTeam 0
sv.teamRatioPercent 100
sv.coopBotRatio 100
sv.coopBotCount 16
sv.coopBotDifficulty 50
sv.voipEnabled 1
sv.voipQuality 3
sv.voipServerRemote 0
sv.voipServerRemoteIP ""
sv.voipServerPort 55125
sv.voipBFClientPort 55123
sv.voipBFServerPort 55124
sv.voipSharedPassword ""
sv.useGlobalRank 1
sv.useGlobalUnlocks 1
sv.noVehicles 0
sv.sponsorText ""
sv.sponsorLogoURL "https://example.com/bf2logo.png"
sv.communityLogoURL "https://example.com/bf2logo.png"
sv.radioSpamInterval 6
sv.radioMaxSpamFlagCount 6
sv.radioBlockedDurationTime 30
sv.numReservedSlots 0
sv.friendlyFireWithMines 1
69 changes: 69 additions & 0 deletions config/bf2/python/bf2/BF2StatisticsConfig-custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ------------------------------------------------------------------------------
# BF2Statistics 3.0.0 - Config File
# ------------------------------------------------------------------------------
# Conventions:
# 0 -> Disable
# 1 -> Enable
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# Debug Logging
# ------------------------------------------------------------------------------
debug_enable = 1
debug_log_path = 'python/bf2/logs' # Relative from BF2 base folder
debug_fraglog_enable = 0 # Detailed 'Fragalyzer' Logs (requires existing folder "mods/<ModName>/logs/")

# ------------------------------------------------------------------------------
# Statistics Enabling
# ------------------------------------------------------------------------------
# 0 = disable statistics, 1 = enable statistics (requires an ASP stats server)
# By disabling the stats, this server will be "non-ranked"
#
# An AuthID and AuthToken are required to post stats data to the ASP backend.
# Contact your local Stats Admin to recieve an AuthID and AuthToken. Both of
# which are NOT to be shared with anyone!
# ------------------------------------------------------------------------------
stats_enable = 1
stats_auth_id = 112950 # Required to post stats data at the end of round.
stats_auth_token = 'GGB6Vj70Nmf98nm7' # Required to post stats data at the end of round.

# ------------------------------------------------------------------------------
# ASP Stats Backend Web Server
# ------------------------------------------------------------------------------
http_backend_addr = 'asp' # Reach ASP over the `bf2-network` docker network. If your ASP is on another host, use its hostname or domain name here.
http_backend_port = 80
http_backend_asp = '/ASP/bf2statistics.php'

# ------------------------------------------------------------------------------
# Snapshot Logging
# ------------------------------------------------------------------------------
# Enables server to make snapshot backups.
# 0 = log only on error sending to backend
# 1 = all snapshots
# ------------------------------------------------------------------------------
snapshot_logging = 1
snapshot_log_path_sent = 'python/bf2/logs/snapshots/sent' # Relative from the BF2 base folder
snapshot_log_path_unsent = 'python/bf2/logs/snapshots/unsent' # Relative from the BF2 base folder

# ------------------------------------------------------------------------------
# Medals Processing
# ------------------------------------------------------------------------------
# Suffix for your custom medals file(s).
# Example: A profile named "custom" = medal_data_custom.py
# ------------------------------------------------------------------------------
medals_custom_data = 'custom'
# A list of mods that xpack (special forces) medals can be earned while playing
# Example: ['mods/xpack', 'mods/bf2', 'mods/ModName'] (all entries must be lower case!!)
medals_xpack_mods = ['mods/bf2sfsp','mods/xpack']

# ------------------------------------------------------------------------------
# Player Manager
# ------------------------------------------------------------------------------
# Local IP address for AI Bots
# ------------------------------------------------------------------------------
pm_ai_player_addr = '127.0.0.1' # Not recommended to change


# ------------------------------------------------------------------------------
# END CONFIGURATION
# ------------------------------------------------------------------------------
Loading

0 comments on commit 889768a

Please sign in to comment.