12/08/25
いつまでも記述無いのもアレなのでとりあえず置いておきます。
適宜、修正更新して下さい。
https://developer.valvesoftware.com/wiki/SteamCMD
が解りやすいです
Windows(C:\srcds にインストールする例)
http://blog.counter-strike.net/wp-content/uploads//2012/04/steamcmd.zip
DLして解凍して steamcmd.exe 実行
プロンプトが立ち上がって
Steam>
と入力待機状態になるので
Steam>login "スチームのユーザーID" "パスワード"
と入力。
※普段ログインしないPCからログインするとスチームガードで弾かれるので
登録されてるメールアドレスに来る認証コードを"パスワード"の後ろに付け足す。
Logging in user 'スチームのユーザーID' to Steam Public...Success.
と表示されればログイン成功
次に
force_install_dir C:\srcds\csgo
と入力してインスコ先設定
app_update 740 validate
で、インスコ実行、終わるまで待つ
Success! App '740' fully installed.
と表示されればインスコ終了。
quit
で必ず終了させること(重要)
C:\srcds\csgo\srcds.exe
をALTキー押しながらドラッグでショートカット作成
そのショートカットをALTキー押しながらダブルクリックでプロパティ
リンク先の設定例(CUI)
C:\srcds\csgo\srcds.exe
から
C:\srcds\csgo\srcds.exe -game csgo +mapgroup mg_bomb +map de_dust2 +port 27015 +mapgroup mg_bomb +sv_lan 0 +maxplayers 12 -console -usercon -tickrate 128
でリンクから起動。
とりあえずこれで入れるのは確認した。(自分の鯖が公開されててもLANタブに表示されるのは仕様なので注意)
GUIで起動する場合は -console を削除すればおk
ただmapgroupとかは指定しないと立ってもちゃんとゲーム出来ないっぽい
最後にポート開放、27015、TCPじゃなくてUDPね
Linux(/srcds/csgo にインストールする例)
http://blog.five-seven.net/?p=107
も参考されたし
ディレクトリ作成
mkdir /srcds
公式プログラムをDL
wget http://media.steampowered.com/client/steamcmd_linux.tar.gz
解凍展開
tar xvfz steamcmd.tar.gz
実行権限付加
chmod +x steam.sh
実行
STEAMEXE=steamcmd ./steam.sh
Steam ID と パスワードでログイン
login <username> <password>
※普段ログインしないPCからログインするとスチームガードで弾かれるので
登録されてるメールアドレスに来る認証コードを"パスワード"の後ろに付け足す。
login <username> <password> <steam guard code>
ログインに成功すると以下の樣に表示される
Logging in user 'スチームのユーザーID' to Steam Public...Success.
以下の様に表示され入力待機状態となる(表示されない場合もある)
Steam>
インストールディレクトリを指定
force_install_dir /srcds/csgo
インストール実行
app_update 740 validate
以下の樣に表示されれば終了
Success! App '740' fully installed.
必ずquitで終了させること(重要)
quit
実行権限付加
chmod +x /srcds/csgo/srcds_run
実行例
/srcds/csgo/./srcds_run -game csgo +mapgroup mg_bomb +map de_dust2 port 27015 +sv_lan 0
終了時
exit
SRCDSはフォアグラウンドとして起動されコンソールが専有されるので
awk と screen を利用してデーモンとして管理する
各種インストール
yum install -y awk screen
導入確認
awk screen (CTRL+A,D で抜ける)
デーモンプログラム作成(ディストリによっては/etc/init.d/)
vi /etc/rc.d/init.d/srcds
#! /bin/bash # # Start the Counter-Strike: Source dedicated server. # # AUTHORS : # # Julien Escario ( pandemik@azilog.net ) # & # Cedric Rochat ( crochat@younics.org ) # & # Cmdr._Firewalker ( cmdr._firewalker@web.de ) # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # chkconfig: 2345 44 56 # Description: srcds # # =========================================== # # What you need: # # Linux # awk # screen # the srcds_l & cstrike files (obtainable via steam) # # How to use: # # Edit the CS_USER-Var to the user running your cs-servers # Edit the DIR-Var to fit your system (just contains the path to the dir that contains srcds_run) # Edit the PARAMS-Var to fit your needs # - standard is startup as internet server # if you use multiple scripts on one system you should change the NAME-var (otherwise # all will be stopped if you run the script with "stop", and status will be useless) # # When this is done, copy the file to /etc/rc.d/init.d (or whereever your system stores the # scripts for starting the services) and set the execute permission. # Now you can link the script to your runlevel-dir, here's an example for runlevel 3: # ln -s /etc/rc.d/init.d/srcds /etc/rc.d/rc3.d/S90srcds # ln -s /etc/rc.d/init.d/srcds /etc/rc.d/rc3.d/K50srcds # or use update-rc.d if you got a system using that tool (like Debian, see manpage) # # Or use it manually like: # ./srcds start # ./srcds stop # # To see the server-console start the script with the parameter "watch". # # DOC by jwm (jwm@counter-strike.de) # # 12/08/25 # chkconfig 対応 & 日本語訳 # by niu # !!!!!!!!!!!!!! CHANGE THIS TO THE USER YOU USE FOR YOUR SERVER !!!!!!!!!!!!!!! # 実行するユーザー名8 CS_USER=root
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
#
# DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS! DIR=/srcds/csgo
#
DAEMON=srcds_run
#
# LAN server: # PARAMS="-game cstrike -nomaster -insecure +sv_lan 1 +maxplayers 16 +map de_dust" # Internet server: PARAMS="-game csgo +mapgroup mg_bomb +map de_dust2 port 27015 +sv_lan 0 -steamcmd_script /srcds/csgo/update.txt $CS_USER"
#
NAME=csgoserver DESC="CS:GO dedicated server"
#
# No edits (should be) necessary beyond this line
#
if [ ! -x `which awk` ]; then echo "このスクリプトにはawkが必要です"; exit 1; fi if [ ! -x `which screen` ]; then echo "このスクリプトにはscreenが必要です"; exit 1; fi
#
if [ `whoami` = root ] then usagetype=root else usagetype=nonroot fi
#
start() { if [ ! -d $DIR ]; then echo "ディレクトリが見つかりません: $DIR!"; exit 1; fi if [ ! -x $DIR/$DAEMON ]; then echo "$DIR/$DAEMON が見つからないか実行出来ません。"; exit 1; fi if status; then echo " ... $DESC: $NAME は既に実行されています。"; exit 1; fi
#
case "$usagetype" in root) su - $CS_USER -c "cd $DIR ; screen -AmdS $NAME ./$DAEMON $PARAMS" ;; nonroot) cd $DIR ; screen -AmdS $NAME ./$DAEMON $PARAMS ;; esac
#
}
#
stop () { if ! status; then echo " ... $DESC $NAME が見つからないか、恐らく起動していません。"; exit 1; fi
#
case "$usagetype" in root) mp=$(su - $CS_USER -c "screen -ls" | awk -F . "\$2 ~ /^$NAME:space:?.*/ {print \$1}" | awk '{print $1}') su - $CS_USER -c "screen -r $tmp -X quit" ;; nonroot) screen -r $(screen -ls | awk -F . "\$2 ~ /^$NAME:space:?.*/ {print \$1}" | awk '{print $1}') -X quit ;; esac }
#
status () { case "$usagetype" in root) su - $CS_USER -c "screen -ls" | grep [.]$NAME:space:? > /dev/null ;; nonroot) screen -ls | grep [.]$NAME:space:? > /dev/null ;; esac }
#
watch () { if ! status; then echo "$DESC $NAME が見つからないか、恐らく動作していません"; exit 1; fi
#
case "$usagetype" in root) tmp=$(su - $CS_USER -c "screen -ls" | awk -F . "\$2 ~ /^$NAME:space:?.*/ {print \$1}" | awk '{print $1}') su - $CS_USER -c "screen -r $tmp" ;; nonroot) screen -r $(screen -ls | awk -F . "\$2 ~ /^$NAME:space:?.*/ {print \$1}" | awk '{print $1}') ;; esac }
#
case "$1" in start) echo "起動中 $DESC: $NAME" start echo " ... 完了!" ;;
#
stop) echo "停止中 $DESC: $NAME" stop echo " ... 完了!" ;;
#
restart) echo "再起動中 $DESC: $NAME" status && stop start echo " ... 完了!" ;;
#
status) if status then echo "$DESC: $NAME は起動しています" else echo "$DESC: $NAME は停止しています" fi ;; watch) watch ;;
#
*) echo "使い方: $0 {start|stop|status|restart|watch}\nwatch から戻る際は ctrl-a,d と入力して下さい" exit 1 ;;
#
esac
#
#
exit 0
アップデートスクリプト作成(参考: thiry氏 http://blog.five-seven.net/ )
vi /srcds/csgo/update.txt
#
login あなたのsteamID パスワード force_install_dir /srcds/csgo app_update 740 quit
実行権限付加
chmod +x /etc/rc.d/init.d/srcds
起動
/etc/rc.d/init.d/srcds start
停止
/etc/rc.d/init.d/srcds stop
再起動
/etc/rc.d/init.d/srcds restart
実行中のコンソールを見る(元に戻る場合はCTRL+A,Dで戻ります。)
/etc/rc.d/init.d/srcds watch or screen -ls でプロセスID取得 screen -r プロセスID で復元
自動起動設定、確認(2-5起動)
chkconfig srcds on chkconfig srcds --list srcds 0:off 1:off 2:on 3:on 4:on 5:on 6:off
自動リスタート例
crontab -e 以下追記(例では毎朝6時に再起動をかける) 00 6 * * * /etc/rc.d/init.d/srcds restart
ポート開放(iptables 例)
iptables -A INPUT -p udp -m udp --dport 27015 -j ACCEPT
iptables 再起動(ディストリによっては/etc/init.d/iptables)
/etc/rc.d/init.d/iptables save /etc/rc.d/init.d/iptables restart
nmap を利用したUDPポート開放確認例(※プログラムを起動してから確認すること)
nmap localhost -sU -p 27015
''''
#
''''
#
''''
#
''''
#