Counter-Strike:Source Server on FreeBSD-5.4

参考にしたサイト
http://www.section6.net/help/cssource.php
http://halflife.luina.net/com_srcds_install.html

PCゲーム Counter-Strike:Source のサーバを FreeBSD にインストールしてみました。サーバを動かして試してみたかっただけなので、本気で公開サーバを作る人はたぶん参考になりません。linux emulation で動作するので、linux_base と linproc が必要みたいです。

linux procfs を /etc/fstab に書く

linproc /compat/linux/proc  linprocfs   rw  0   0

マウントする ( or 再起動 )

# mount /compat/linux/proc

ちゃんと確認してないけど、linux.ko とか linux_base とか linux procfs とかがないと起動しない (Segmentation fault で落ちる)と思われる。今動いているサーバの linux_base は linux_base-8-8.0_14。Linux だときっとこんな苦労ないんだろうなあ、とか。

データ取得して展開

% fetch http://www.steampowered.com/download/hldsupdatetool.bin
% chmod +x hldsupdatetool.bin
% ./hldsupdatetool.bin
<snip>
Enter 'yes' to accept this agreement, 'no' to decline:

規約に同意するかと聞かれるので

yes[Enter]

と入力。解凍したディレクトリに steam が出来上がる。usage でも出るかと思って実行してみた

% ./steam
Checking bootstrapper version ...
Getting version 17 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command

アップデートされたらしい。もう一回実行する

% ./steam
Checking bootstrapper version ...

Use: steam -command <command> [parameters] [flags]

Commands:

 update: Install or update HLDS

   parameters:
      -game <game>            -   Game name: use 'list' to see available games
      -dir <installdir>       -   HLDS Install dir
      (if dir not specified, will use value from last run of tool)

   flags:
      -verify_all             -   Verify all HLDS files are up to date
      -retry                  -   Automatically retry every 30 seconds if the Steam Network is busy
      -remember_password      -   Remember password (if a username is supplied)

   For example: steam -command update -game cstrike -dir /hlds

 version: View installed versions

 list: View available games

Optional parameters for all commands:

      -username <username>    -   Steam account username (only needed to access limited content)
      -password <password>    -   Steam account password (only needed to access limited content)

Usage が表示されましたよ。game を update しよう

% ./steam -command update -game "Counter-Strike Source" -dir /var/tmp/cs-source/
Checking bootstrapper version ...
Updating Installation
No installation record found at /var/tmp/cs-source/
Checking/Installing 'Counter-Strike Source Shared Content' version 46
Downloading: /var/tmp/cs-source/\cstrike\bin\server.dll
Downloading: /var/tmp/cs-source/\cstrike\bin\server_i486.so
<snip>
Downloading: /var/tmp/cs-source/\srcds_amd
Downloading: /var/tmp/cs-source/\srcds_i486
Downloading: /var/tmp/cs-source/\srcds_i686
Downloading: /var/tmp/cs-source/\srcds_run

HLDS installation up to date

起動してみるか

% ./srcds_run -game "Counter-Strike Source" -secure +map de_dust +maxplayers 32
Invalid game type 'Counter-Strike' sepecified.
2006年 2月28日 火曜日 07時29分04秒 JST: Server Failed
Auto detecting CPU
Using default binary.
Auto-restarting the server on crash
Unable to find gameinfo.txt. Solutions:

1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir
2. Run vconfig to specify which game you're working on.
3. Add -game <path> on the command line where <path> is the directory that gameinfo.txt is in.
Unable to find gameinfo.txt. Solutions:

1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir
2. Run vconfig to specify which game you're working on.
3. Add -game <path> on the command line where <path> is the directory that gameinfo.txt is in.

Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem

ゲーム名が違うみたいだ。cstrike で再トライ

% ./srcds_run -game cstrike -secure +map de_dust +maxplayers 32

Auto detecting CPU
Using default binary.
Auto-restarting the server on crash

Console initialized.
Attempted to create unknown entity type event_queue_saveload_proxy!
Game.dll loaded for "Counter-Strike: Source"
maxplayers set to 32
maxplayers set to 32
Network: IP 192.168.x.x, mode MP, dedicated Yes, ports 27015 SV / 27005 CL
Executing dedicated server config file
Summary:  339 resources total 14.29 Mb, 21.29 % of capacity
net.cpp (825) : Assertion Failed: 0 == iRet
net.cpp (828) : Assertion Failed: 0 == iRet
couldn't exec server.cfg
Adding master server 69.28.151.162:27011
Adding master server 68.142.72.250:27011
Connection to Steam servers successful.
   VAC secure mode is activated.

サービスあがったみたい

% sockstat
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
cstrike  srcds_i486 4085  4  udp4   *:27015               *:*
cstrike  srcds_i486 4085  5  udp4   *:27020               *:*
cstrike  srcds_i486 4085  6  udp4   *:27005               *:*
cstrike  srcds_i486 4085  7  tcp4   192.168.x.x:27015     *:*
cstrike  srcds_i486 4085  12 udp4   *:26900               *:*
cstrike  srcds_i486 4084  4  udp4   *:27015               *:*
cstrike  srcds_i486 4084  5  udp4   *:27020               *:*
cstrike  srcds_i486 4084  6  udp4   *:27005               *:*
cstrike  srcds_i486 4084  7  tcp4   192.168.x.x:27015     *:*
cstrike  srcds_i486 4084  12 udp4   *:26900               *:*
cstrike  srcds_i486 4082  4  udp4   *:27015               *:*
cstrike  srcds_i486 4082  5  udp4   *:27020               *:*
cstrike  srcds_i486 4082  6  udp4   *:27005               *:*
cstrike  srcds_i486 4082  7  tcp4   192.168.x.x:27015     *:*
cstrike  srcds_i486 4082  12 udp4   *:26900               *:*

サーバは無事起動しているようだ。接続も出来るね。update するときとゲーム走らす時で名前が違うのはどうかと思うなあ。あと、Pentium3 のマシンだから i686 だと思うんだけど、なんで i486 であがってるんだろう?emulation 環境だから?-binary とか指定すればいいのかな?

サーバの設定とかはここを見て勉強するか
http://halflife.luina.net/server_cfg.html

公開するサーバレベルにしたいんだった、起動するユーザ別に作ったりとか、セキュリティ(jail とか)とか色々考えなきゃダメなんだろうな。僕は NAT の中で動かしてみただけだけど。