initial commit - cross reference with 5th port - obviously has compile errors

This commit is contained in:
LetterJay
2016-07-03 02:17:19 -05:00
commit 35a1723e98
4355 changed files with 2221257 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
About:
This is a toolset to manage a production server of tgstation13 (or its forks). It includes an update script that is able to update the server without having to stop or shutdown the server (the update will take effect next round) and a script to start the server and restart it if it crashes (optional, requires registry tweaks to disable the Windows crash dialog system wide)
This will force a live tracking of the configured git repo, so no local modifications are allowed. (this is to avoid issues with merge conflicts and because I'm too lazy to make the script detect them)
Install:
Move this folder to where you want your server to run from (you may also rename this folder if you wish)
Right click on config.bat and click edit.
Configure the port, selected map file, and the like, You may configure the location of git, but if you installed using git for windows, we will auto detect it if its not in path.
You may also need to change the location of the gitrepo url, and if you renamed your dme/"dream maker environment" file, you will need to change the project name configuration setting to be the name of your dme minus the extension (eg: if you renamed tgstation.dme to ntstation.dme, project name should be set to ntstation
After that, just run install.bat and hope for no error.
It will clone the git repo, setup some folders, and add cross reference links everywhere.
Optional:
If you plan to use the start-server script to watch the server and restart it if it crashes, you should run the "disable crash dialog.reg" registry script to disable the "program.exe has stopped working" dialog. This will get disabled system wide so if you rely on this dialog, you shouldn't run the script.
Even without this, byond stopping the world from two many critical errors (like infinite loops and recursions) will still be detected.
Usage:
The install script will make a few folders:
gamecode
This will house two copies of the game code, one for updating and one for live. When updating, it will automatically swap them.
gamedata
This contains the data, config, and cfg folders from the code. They are stored here and a symbolic link is created in the code folders pointing to here.
This also makes backing them up easy.
(you may copy and paste your existing data/config/cfg folders here after the install script has ran.)
bot
This is a copy of the bot folder. you should run the bot from here. a link to coredata.py and nudge.py is created in the code folders so that the game can use the announcement feature.
The start server script and update script will send messages out thru the bot, but if its not running or python is not installed, they will gracefully continue what they are doing.
gamefolder
This is a symbolic link pointing to current "live" folder.
When the server is updated, we just point this to the updating folder so that the update takes place next round.
bin
This contains random helper batch files.
Running these on their own is a bad idea.
To update the server, just run update server.bat. (it will git pull, compile, all that jazz)
It will ask you if you want to apply the update live. 99.9% of the time, this will not cause issues. The only issues it can cause relate to changes to media files(images(but not icons)/css/html/sound not stored in the RSC. but only new clients will see those issues, and at worst, its a minor graphical glitch.
You may remove the pause in the update script at line 90 if you like.
To run the server, just run start server.bat
It will automatically redirect the runtimes to data/logs/runtimes/runtime-YYYY-MM-DD.log.
(Note: It will not automatically roll them over, but every time it crashes or stops it will have a new log file.)
When it starts dreamdaemon, it instructs byond to close down dreamdaemon if the world stops for any reason, this includes hitting the stop button, dreamdaemon shutting the world down because of too many runtimes/infinite loops.
If dreamdaemon ever stops while the start server script is running, the script will restart it automatically.
(Note: The script can not detect hangs or lockups)

View File

@@ -0,0 +1,19 @@
@echo off
@title NT IRC BOT
echo Welcome to the start bot script, This will start the bot and make sure it stays running. This assumes python in the path. To continue, press any key or wait 60 seconds.
timeout 60
cd bot
:START
call ..\bin\getcurdate.bat
if not exist ..\gamedata\data\logs\bot mkdir ..\gamedata\data\logs\bot\
cls
echo NT IRC Bot
echo Bot Running. Watching for Bot exits.
start /WAIT python NanoTrasenBot.py >>..\gamedata\data\logs\bot\bot-%CUR_DATE%.txt
cls
echo NT IRC Bot
echo Bot exit detected. Restarting in 15 minutes.
REM this is so long because we want to avoid the bot spamming the server and getting klined/glined/or akilled
timeout 900
goto :START

View File

@@ -0,0 +1,24 @@
@echo off
@title SERVER WATCHDOG
call config.bat
call bin\findbyond.bat
echo Welcome to the start server watch dog script, This will start the server and make sure it stays running. To continue, press any key or wait 60 seconds.
timeout 60
if not exist gamedata\data\logs\runtimes mkdir gamedata\data\logs\runtimes\
@python bot\nudge.py "WATCHDOG" "Watch Dog online. Starting server" >nul 2>nul
:START
call bin\getcurdate.bat
cls
echo Watch Dog.
echo Server Running. Watching for server exits.
start /WAIT /ABOVENORMAL "" dreamdaemon.exe gamefolder\%PROJECTNAME%.dmb -port %PORT% -trusted -close -log "data\logs\runtimes\runtime-%CUR_DATE%.log"
cls
echo Watch Dog.
echo Server exit detected. Restarting in 60 seconds.
@python bot\nudge.py "WATCHDOG" "Server exit detected. Restarting server in 60 seconds." >nul 2>nul
timeout 60
goto :START

View File

@@ -0,0 +1,87 @@
@echo off
@title Server Updater
set HOME = %USERPROFILE%
call config.bat
call bin\getcurdate.bat
echo This will handle downloading git, compiling the server, and applying the update.
echo ready?
timeout 120
if exist updating.lk (
echo ERROR! A current update script has been detected running. if you know this is a mistake:
pause
echo Please be double sure that an update script is not currently running, if you think one might be, close this window. otherwise:
pause
)
if exist rotating.lk (
echo ERROR! A current map rotation operation has been detected running. IT IS STRONGLY RECOMMENDED YOU DO NOT UPDATE RIGHT NOW. if you know this is a mistake, and that the game server is not currently rotating the map:
pause
echo IT IS STRONGLY RECOMMENDED YOU DO NOT UPDATE RIGHT NOW. If a map rotation script runs at the same time as an update script the server will generally break in ways not trivial to recover from. Are you REALLY sure? Please close this window if you are not, otherwise:
pause
)
@del /F /Q rotating.lk >nul 2>nul
echo lock>updating.lk
rem if the first arg to nudge.py is not a channel, it is treated as the "source"
if not defined UPDATE_LOG_CHANNEL set UPDATE_LOG_CHANNEL="UPDATER"
python bot\nudge.py %UPDATE_LOG_CHANNEL% "Update job started" >nul 2>nul
call bin\updategit.bat
if %GIT_EXIT% neq 0 (
echo git pull failed. Aborting update
python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git pull failed. Aborting update"
@del updating.lk >nul 2>nul
pause
exit /b 1
)
if defined PUSHCHANGELOGTOGIT (
echo compiling change log
python tools\ss13_genchangelog.py html/changelog.html html/changelogs
if %ERRORLEVEL% == 0 (
echo pushing compiled changelog to server
git add -u html/changelog.html
git add -u html/changelogs
git commit -m "Automatic changelog compile"
if %ERRORLEVEL% == 0 (
git push
)
REM an error here generally means there was nothing to commit.
)
)
call bin\findab.bat
call bin\copyfromgit.bat
if not defined PUSHCHANGELOGTOGIT (
echo compiling change log
cd gamecode\%AB%
call python tools\ss13_genchangelog.py html/changelog.html html/changelogs
cd ..\..
)
echo building script.
call bin\build.bat
if %DM_EXIT% neq 0 (
echo DM compile failed. Aborting.
python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed Aborting update." >nul 2>nul
@del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
if not defined NOWAITUPDATES (
echo OK, compiled and ready. So at the hit of a button, we can apply the update live. Technically speaking, it's best to wait until near round end, but unless a html/css/js file in the code had been deleted, edited, or moved recently, no ill effects of applying the update will happen, and the worst is that new clients have display oddities relating to in game windows. Existing connections should have no issue.
echo Ready?
pause
)
@del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
python bot\nudge.py %UPDATE_LOG_CHANNEL% "Update job finished. Update will take place next round." >nul 2>nul
echo Done. The update will automatically take place at round restart.
timeout 300

View File

@@ -0,0 +1,26 @@
@echo off
call config.bat
call bin/findbyond.bat
set DME_FOLDER=gamefolder\
if defined AB set DME_FOLDER=gamecode\%AB%\
set DME_LOCATION=%DME_FOLDER%%PROJECTNAME%.dme
set MDME_LOCATION=%DME_FOLDER%%PROJECTNAME%.mdme
@del %MDME_LOCATION% >nul 2>nul
if defined MAPROTATE set MAPFILE=%MAPROTATE%
if not defined MAPFILE goto BUILD
echo #define MAP_OVERRIDE >>%MDME_LOCATION%
echo #include "_maps\%MAPFILE%.dm" >>%MDME_LOCATION%
:BUILD
echo #define SERVERTOOLS 1 >>%MDME_LOCATION%
type %DME_LOCATION% >>%MDME_LOCATION%
dm %MDME_LOCATION%
set DM_EXIT=%ERRORLEVEL%
@del %DME_FOLDER%%PROJECTNAME%.dmb >nul 2>nul
@del %DME_FOLDER%%PROJECTNAME%.rsc >nul 2>nul
@move %DME_FOLDER%%PROJECTNAME%.mdme.dmb %DME_FOLDER%%PROJECTNAME%.dmb >nul 2>nul
@move %DME_FOLDER%%PROJECTNAME%.mdme.rsc %DME_FOLDER%%PROJECTNAME%.rsc >nul 2>nul

View File

@@ -0,0 +1,22 @@
echo Removing old files
rem delete the symlinks manually to ensure their targets don't get recursively deleted
rmdir /q gamecode\%AB%\data >nul 2>nul
rmdir /q gamecode\%AB%\config >nul 2>nul
rmdir /q gamecode\%AB%\cfg >nul 2>nul
del /q gamecode\%AB%\nudge.py >nul 2>nul
del /q gamecode\%AB%\CORE_DATA.py >nul 2>nul
del /S /F /Q gamecode\%AB% >nul 2>nul
echo Copying files
xcopy gitrepo gamecode\%AB% /Y /X /K /R /H /I /C /V /E /Q /EXCLUDE:copyexclude.txt >nul
mkdir gamecode\%AB%\.git\logs
copy gitrepo\.git\logs\HEAD gamecode\%AB%\.git\logs\HEAD /D /V /Y >nul
mklink gamecode\%AB%\nudge.py ..\..\bot\nudge.py >nul
mklink gamecode\%AB%\CORE_DATA.py ..\..\bot\CORE_DATA.py >nul
rmdir /q gamecode\%AB%\data >nul 2>nul
rmdir /s /q gamecode\%AB%\data >nul 2>nul
mklink /d gamecode\%AB%\data ..\..\gamedata\data >nul
mklink /d gamecode\%AB%\config ..\..\gamedata\config >nul
mklink /d gamecode\%AB%\cfg ..\..\gamedata\cfg >nul

View File

@@ -0,0 +1,29 @@
@del gamecode\a\updater.temp >nul 2>nul
@del gamecode\b\updater.temp >nul 2>nul
echo test >gamefolder\updater.temp
if exist gamefolder\%PROJECTNAME%.rsc.lk (
rem we attempt to delete the lock file to see if the server is currently running.
del /q gamefolder\%PROJECTNAME%.rsc.lk >nul 2>nul
if exist gamefolder\%PROJECTNAME%.rsc.lk set RUNNING=1
)
if exist gamecode\a\updater.temp (
if defined RUNNING (
echo Current folder detected to be the "A" folder. Game is currently running. Updating to the "B" folder.
set AB=b
) else (
echo Current folder detected to be the "A" folder. Game is not currently running, Updating to the "A" folder.
set AB=a
)
) else if exist gamecode\b\updater.temp (
if defined RUNNING (
echo Current folder detected to be the "B" folder. Game is currently running, Updating to the "A" folder.
set AB=a
) else (
echo Current folder detected to be the "B" folder. Game is not currently running, Updating to the "B" folder.
set AB=b
)
)
@del gamefolder\updater.temp >nul 2>nul

View File

@@ -0,0 +1,27 @@
@echo off
@dm.exe -h >nul 2>nul
IF %ERRORLEVEL% NEQ 9009 (
goto :eof
)
set PATH=%PATH%;%BYOND_LOCATION_PATH%
@dm.exe -h >nul 2>nul
IF %ERRORLEVEL% NEQ 9009 (
goto :eof
)
@"c:\Program Files (x86)\BYOND\bin\dm.exe" -h >nul 2>nul
IF %ERRORLEVEL% NEQ 9009 (
set "PATH=%PATH%;c:\Program Files (x86)\BYOND\bin\"
goto :eof
)
@"c:\Program Files\BYOND\bin\dm.exe" -h >nul 2>nul
IF %ERRORLEVEL% NEQ 9009 (
set "PATH=%PATH%;c:\Program Files\BYOND\bin\"
goto :eof
)
echo byond not found. Aborting. If byond is installed, set the GIT_LOCATION variable inside config.bat
timeout 60
exit 11

View File

@@ -0,0 +1,32 @@
@echo off
REM check if git is already in path
git --version >nul 2>nul && goto :eof
REM now lets try our override.
set PATH=%PATH%;%GIT_LOCATION_PATH%
@git --version >nul 2>nul && goto :eof
REM credit to sschuberth@http://stackoverflow.com/questions/8507368/finding-the-path-where-git-is-installed-on-a-windows-system
REM Read the Git for Windows installation path from the Registry.
:REG_QUERY
for /f "skip=2 delims=: tokens=1*" %%a in ('reg query "HKLM\SOFTWARE%WOW%\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1" /v InstallLocation 2^> nul') do (
for /f "tokens=3" %%z in ("%%a") do (
set GIT=%%z:%%b
)
)
if "%GIT%"=="" (
if "%WOW%"=="" (
rem Attempt to find it on the 32bit register section
set WOW=\Wow6432Node
goto REG_QUERY
)
)
set PATH=%GIT%bin;%PATH%
@git --version >nul 2>nul && goto :eof
echo Git not found. Aborting. If git is installed, set the GIT_LOCATION variable inside config.bat
timeout 60
exit 10

View File

@@ -0,0 +1,3 @@
@echo off
FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') DO set DTS=%%a
set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%

View File

@@ -0,0 +1,2 @@
@echo off
for /f "delims=" %%x in ('cscript /nologo unixtime.vbs') do set UNIXTIME=%%x

View File

@@ -0,0 +1,32 @@
@echo off
@title Map Rotator
if not exist setnewmap.bat exit 11
call setnewmap.bat
cd ..
if exist updating.lk exit 21
if exist rotating.lk exit 22
if not exist config.bat exit 12
call config.bat
echo lock>rotating.lk
cls
echo Rotating map to %MAPROTATE%
call bin\findab.bat
cls
echo Rotating map to %MAPROTATE%
call bin\copyfromgit.bat
cls
echo Rotating map to %MAPROTATE%
call bin\build.bat
@del /F /Q rotating.lk >nul 2>nul
if %DM_EXIT% neq 0 exit 31
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB%

View File

@@ -0,0 +1 @@
WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now())

View File

@@ -0,0 +1,18 @@
call bin\findgit.bat
echo Updating repo
cd gitrepo
git branch backup-%CUR_DATE% >nul 2>nul
git fetch
set GIT_EXIT=%ERRORLEVEL%
if %GIT_EXIT% neq 0 goto END
git checkout %REPO_BRANCH%
set GIT_EXIT=%ERRORLEVEL%
if %GIT_EXIT% neq 0 goto END
git reset origin/%REPO_BRANCH% --hard
set GIT_EXIT=%ERRORLEVEL%
if %GIT_EXIT% neq 0 goto END
git pull --force
set GIT_EXIT=%ERRORLEVEL%
:END
cd ..

View File

@@ -0,0 +1,50 @@
@echo off
REM Server Tools configuration file. Lines starting with REM are comments and ignored.
REM on/off config options are considered "on" if they have anything (even 0) and "off" if they are blank or commented out.
REM This must be set to the name of your dme without the .dme part. (should be fine leaving this alone unless you renamed the code)
set PROJECTNAME=tgstation
REM location of the repo.
set REPO_URL=https://github.com/tgstation/-tg-station.git
REM set REPO_URL=git@github.com:tgstation/-tg-station.git
REM What branch of the repo to use.
set REPO_BRANCH=master
REM what map file to use. This should be the name of the dm, not dmm (and without the .dm part) (defaults to what ever is ticked in the dme)
set MAPFILE=tgstation2
REM set MAPFILE=metastation
REM set MAPFILE=ministation
REM port to use (only used to start the server in the start-server script)
set PORT=1337
REM This is the channel to log updates to. Leave blank to log to the normal channel (this is done via the tgstation bot, optional)
set UPDATE_LOG_CHANNEL=#coderbus
REM overrides the prompt to live apply the updates in update server.bat if set to anything other than a null string.
REM It is generally safe to live apply the updates, they don't take effect until the next round. the only concern is that some media files may get loaded by new clients before the next round. These files aren't edited 99% of the time, so its not a real concern, but I kept the prompt the default for compatibility sake.
set NOWAITUPDATES=
REM Attempt to push the compiled changelog to the configured git server? (set to anything)
REM This requires you configure git with authentication for the upstream server. (the ssh key should be stored in c:\users\USERNAME_HERE\.ssh\ as the filename id_rsa (if that still doesn't work, try c:\program files\git\.ssh\id_rsa))
set PUSHCHANGELOGTOGIT=
REM location of git. The script will attempt to auto detect this, but if it fails, you can set it manually.
REM This will be added to the end of path as is (only for the batch file, not the whole system)
REM github for windows users see http://www.chambaud.com/2013/07/08/adding-git-to-path-when-using-github-for-windows/ (an example is provided below)
set GIT_LOCATION_PATH=
REM set GIT_LOCATION_PATH=C:\Users\<user>\AppData\Local\GitHub\PortableGit_<GUID>\bin;C:\Users\<USER>\AppData\Local\GitHub\PortableGit_<GUID>\cmd
REM path to the byond bin folder. (if blank, we look in path, program files/byond/bin, and program files (x86)/byond/bin) (same rules as git path above)
set BYOND_LOCATION_PATH=D:\Program Files (x86)\BYOND\bin

View File

@@ -0,0 +1,9 @@
//This is a list of files to exclude from copying. See xcopy's documentation for /exclude for more info.
//
gitrepo\config\
gitrepo\data\
gitrepo\bot\
gitrepo\cfg\
gitrepo\.git\

View File

@@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting]
"DontShowUI"=dword:00000001

View File

@@ -0,0 +1,80 @@
@echo off
@title Server Tools Installer.
set HOME = %USERPROFILE%
call config.bat
echo This will download the game code from git and install the all the files and folders and symbolic links needed to use the server tools in to the current directory.
echo This requires git be installed.
echo Once this is done, you can safely delete this file if you wish.
echo Ready?
pause
call bin/findgit.bat
echo Downloading repo....
git clone %REPO_URL% gitrepo
IF %ERRORLEVEL% NEQ 0 (
echo git clone failed. aborting.
pause
goto ABORT
)
cd gitrepo
git checkout %REPO_BRANCH%
cd ..
echo Repo downloaded.
echo Setting up folders...
mkdir gamecode\a
mkdir gamecode\b
mkdir gamecode\override
mkdir gamedata
mkdir bot
echo Copying things around....
echo (1/3)
xcopy gitrepo\data gamedata\data /Y /X /K /R /H /I /C /V /E /Q >nul
xcopy gitrepo\config gamedata\config /Y /X /K /R /H /I /C /V /E /Q >nul
xcopy gitrepo\cfg gamedata\cfg /Y /X /K /R /H /I /C /V /E /Q >nul
xcopy gitrepo\bot bot /Y /X /K /R /H /I /C /V /E /Q >nul
echo (2/3)
xcopy gitrepo gamecode\a /Y /X /K /R /H /I /C /V /E /Q /EXCLUDE:copyexclude.txt >nul
mkdir gamecode\a\.git\logs\
copy gitrepo\.git\logs\HEAD gamecode\a\.git\logs\HEAD /D /V /Y >nul
echo (3/3)
xcopy gitrepo gamecode\b /Y /X /K /R /H /I /C /V /E /Q /EXCLUDE:copyexclude.txt >nul
mkdir gamecode\b\.git\logs >nul
copy gitrepo\.git\logs\HEAD gamecode\b\.git\logs\HEAD /D /V /Y >nul
echo done.
echo Setting up symbolic links.
mklink gamecode\a\nudge.py ..\..\bot\nudge.py
mklink gamecode\a\CORE_DATA.py ..\..\bot\CORE_DATA.py
mklink /d gamecode\a\data ..\..\gamedata\data
mklink /d gamecode\a\config ..\..\gamedata\config
mklink /d gamecode\a\cfg ..\..\gamedata\cfg
mklink gamecode\b\nudge.py ..\..\bot\nudge.py
mklink gamecode\b\CORE_DATA.py ..\..\bot\CORE_DATA.py
mklink /d gamecode\b\data ..\..\gamedata\data
mklink /d gamecode\b\config ..\..\gamedata\config
mklink /d gamecode\b\cfg ..\..\gamedata\cfg
mklink /d gamefolder gamecode\a
echo Compiling for the first time.
echo Compiling change log.
cd gamecode\a
call python tools\ss13_genchangelog.py html/changelog.html html/changelogs
cd ..\..
echo Compiling game.
call bin\build.bat
if %DM_EXIT% neq 0 echo DM compile failed.
echo Done. You may start the server using the start server program or change the game config in gamedata\config
pause
:ABORT