Moves tgstation-server (#27904)

* Removes tgstation-server

* Add the server submodule

* Bring it up to date
This commit is contained in:
Jordan Brown
2017-06-01 10:16:22 -04:00
committed by Leo
parent ca1a8416e5
commit e046d88138
27 changed files with 5 additions and 1101 deletions

4
.gitmodules vendored Normal file
View File

@@ -0,0 +1,4 @@
[submodule "tools/tgstation-server"]
path = tools/tgstation-server
url = https://github.com/tgstation/tgstation-server
branch = master

View File

@@ -1,24 +0,0 @@
@echo off
title Automated Error Fixer.
echo This will reset some things, the byond server (DreamDaemon) and the start server script must not be running. Some error messages are normal.
echo You will be prompted to press any key 3 times
pause
pause
pause
cls
echo Resetting folders
mkdir gamecode\a
mkdir gamecode\b
del /S /F /Q gamefolder >nul 2>nul
rmdir /S /q gamefolder
mklink /d gamefolder gamecode\a
call bin\findab.bat
cls
echo Re-Initializing code
call bin\copyfromgit.bat
cls
echo Recompiling the game. If you plan to update or testmerge you can just close this program now and continue.
call bin\build.bat
cls
echo Done! (hopefully)
pause

View File

@@ -1,112 +0,0 @@
@echo off
@title Server Updater
SETLOCAL ENABLEDELAYEDEXPANSION
set HOME = %USERPROFILE%
call config.bat
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"
call bin\getcurdate.bat
call bin\findgit.bat
echo This will handle merging a pr locally, compiling the server, and applying the PR test job.
:PROMPT
SET /P UserInput=Please enter the pr number (without a # or anything of the sorts):
SET /A PR=UserInput
if %PR% EQU %UserInput% (
if %PR% GTR 0 (
echo updating to pr %PR%
) else (
echo Bad input
goto PROMPT
)
) else (
echo Bad input
goto PROMPT
)
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
)
echo lock>updating.lk
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "PR test job started. Merging PR #%PR% locally" >nul 2>nul
cd gitrepo
git fetch -f origin pull/%PR%/head:pr-%PR%
if %ERRORLEVEL% neq 0 (
cd ..
echo git fetch failed. Aborting test merge.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git fetch failed. Aborting test merge"
del updating.lk >nul 2>nul
pause
exit /b 1
)
git merge pr-%PR%
if %ERRORLEVEL% neq 0 (
cd ..
echo git merge of PR #%PR% failed. Aborting test merge
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "git merge of PR #%PR% failed. Aborting PR test merge" >nul 2>nul
cd gitrepo
git merge --abort
if !ERRORLEVEL! neq 0 (
echo ERROR: Error aborting test merge, resetting repo.
cd ..
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Error aborting test merge, resetting git repo to head" >nul 2>nul
cd gitrepo
git reset --hard
git clean -fd
<nul set /p TRIM="set PR=" > bin/activepr.bat
del /F /Q prtestjob.lk >nul 2>nul
echo NOTICE: We had to reset the repo's state, all other active test merges were undone.
)
cd ..
del updating.lk >nul 2>nul
pause
exit /b 1
)
cd ..
echo %PR%>>prtestjob.lk
<nul set /p TRIM=%PR% >> bin/activepr.bat
echo ##################################
echo ##################################
echo:
echo Test merging pr done, compiling in 10 seconds. If you want to preform other actions (like more test merges) You can close this now and do them.
echo:
del updating.lk >nul 2>nul
timeout 10
echo lock>updating.lk
call bin\findab.bat
call bin\copyfromgit.bat
echo compiling change log
cd gamecode\%AB%
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. Aborting.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed. Aborting test merge." >nul 2>nul
del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Test merge job finished. Test merge will take place next round." >nul 2>nul
echo Done. The test merge will automatically take place at round restart.
timeout 300

View File

@@ -1,47 +0,0 @@
@echo off
title Server Boot Detected.
echo This script is only meant to start byond when the server first boots, do not manually run this.
echo If you manually ran this, close this window NOW.
timeout 15
start cmd /c "Start Bot.bat"
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
mkdir gamecode\a
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
mkdir gamecode\b
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
del /S /F /Q gamefolder >nul 2>nul
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
rmdir /S /q gamefolder
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
mklink /d gamefolder gamecode\a
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Prepping code
call bin\findab.bat
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Re-Initializing code
call bin\copyfromgit.bat
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Re-Initializing code
cls
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Compiling the game. If you plan to update or testmerge you can just close this program now and continue.
call bin\build.bat
cls
echo Server boot detected. Starting byond and Space Station 13.
echo Starting server and bot.
start cmd /c "Start Server.bat"
timeout 10

View File

@@ -1,111 +0,0 @@
# Tgstation Toolkit:
This is a toolset to manage a production server of /tg/Station13 (and 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) as well as systems for fixing errors and merging GitHub Pull Requests locally.
Generally, updates force a live tracking of the configured git repo, resetting local modifications. If you plan to make modifications, set up a new git repo to store your version of the code in, and point this script to that in the config (explained below). This can be on github or a local repo using file:/// urls.
These tools require UAC to be disabled. (There has been limited luck getting it to work under UAC on windows 10 using run as admin, but in other versions of windows, running as admin resets the current directory and this breaks things)
(Note: There is no security risk to disabling UAC because UAC is not a security boundary, there exists active unpatched exploits against it that have been around since vista and work up to windows 10)
## Install:
1. Move this folder to where you want your server to run from (you may also rename this folder if you wish)
1. Right click on `config.bat` and select `Edit`.
1. Configure the port, git repo, and other setting, 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.
1. You may also need to change the location of the git repo 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`
1. Finally, 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.bat` script to start the server and restart it if it crashes, you need to 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 should skip this step.
## Usage:
### 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/` and `config/` folders from the code. They are stored here and a symbolic link is created in the `gamecode/` folders pointing to here.
* This also makes backing them up easy.
(you may copy and paste your existing `data/` and `config/` 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 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.
* `gitrepo/`
* This contains the actual git repository, all changes in here will be overwritten during update operations, the configured branch will always be forced to track from live.
* On the first update of the day, the current code state is saved to a branch called `backup-YYYY-MM-DD` before updating, to make local reverts easy.
* Following update operations on the same day do not make branches because I was too lazy to detect such edge cases.
* `bin/`
* This contains random helper batch files.
* Running these on their own is a bad idea.
### Starting the game server:
To run the game server, Run `Start Server.bat`
It will restart the game server if it shutdowns for any reason, with delays if the game server had recently been (re)started.
### Updating the server:
To update the server, just run `Update Server.bat`. (it will git pull, compile, all that jazz)
(Note: Updating automatically does a code reset, clearing ALL changes to the local git repo, including test merges (explained below) and manual changes (This will not change any configs/settings or clear any data in the `gamedata/` folder))
Updates do not require the server to be shutdown, changes will apply next round if the server is currently running.
Updates create a branch with the current state of the repo called `backup-YYYY-MM-DD` (only one is created in any given day)
There is also a `Update without resetting.bat` file that does the same without resetting the code, used to update without clearing test merges or local changes. Prone to merge conflicts.
### Locally merge GitHub Pull Requests (PR test merge):
This feature currently only works if github is the remote(git server), it could be adapted for gitlab as well.
Running these will merge the pull request then recompile the server, changes take effect the next round if the server is currently running.
There are multiple flavors:
* `Update To PR.bat`
* Updates the server, resetting state, and merges a PR(Pull Request) by number.
* `Merge PR Without Updating.bat`
* Merges a PR without updating the server before hand or resetting the state (can be used to test merge multiple PRs).
You can clear all active test merges using `Reset and Recompile.bat` (explained below)
### Resetting, Recompiling, and troubleshooting.
* `Recompile.bat`
* Just recompiles the game code and stages it to apply next round
* `Reset and Recompile.bat`
* Like the above but resets the git repo to the state of the last update operation (clearing any changes or test merges) (Does not reset `gamedata/` data/settings)
* Generally used to clear out test merges
* `Fix Errors.bat`
* Requires the server not be running, rebuilds the staging A/B folders and then does all of the above. (Used to fix errors that can prevent the server from starting or cause it to crash on reboot)
### Using the bot
1. Install python 3
1. Edit the config in `bot/` as needed
1. Start the bot using the `Start Bot.bat` file
### Starting everything when the computer/server boots
1. Use autologin to set it up so the user account logs in at boot
* (There are some security implications with doing this, this is only a tiny bit more secure then putting a file on the hard drive with the server's remote login password titled `totally not a password.txt`)
* https://technet.microsoft.com/en-us/sysinternals/bb963905
1. Setup something to run OnServerBoot.bat on login (setting up a link/shortcut to this file in the startup folder of the start menu works, creating a scheduled task in windows administrative tools also works)
1. OnServerBoot.bat does not update, but it does re-compile and reinitialize the A/B folders.
### Updating byond after this is all setup
1. Download installer from byond website
1. Close watch dog/start server script
1. Wait for current round to end
1. Exit DreamDeamon
1. Run installer
1. After installing, run recompile.bat (or update if you want)
1. Run start server.bat

View File

@@ -1,51 +0,0 @@
@echo off
@title Server Updater
set HOME = %USERPROFILE%
call config.bat
call bin\getcurdate.bat
echo This will handle recompiling the server, and applying the new version.
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
)
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"
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Recompile job started" >nul 2>nul
call bin\findab.bat
call bin\copyfromgit.bat
echo compiling change log
cd gamecode\%AB%
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. Aborting.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed Aborting recompile." >nul 2>nul
del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Recompile finished. Recompiled code will take place next round." >nul 2>nul
echo Done. The recompile will automatically take place at round restart.
timeout 300

View File

@@ -1,66 +0,0 @@
@echo off
@title Server Updater
set HOME = %USERPROFILE%
call config.bat
call bin\getcurdate.bat
call bin\findgit.bat
echo This will handle resetting the git repo, recompiling the server, and applying the new version.
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
)
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"
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Reset local changes job started" >nul 2>nul
cd gitrepo
git reset --hard
git clean -df
cd ..
echo ##################################
echo ##################################
echo:
echo Resetting done, compiling in 10 seconds. If you want to preform other actions (like test merges) You can close this now and do them.
echo:
del updating.lk >nul 2>nul
timeout 10
echo lock>updating.lk
call bin\findab.bat
call bin\copyfromgit.bat
echo compiling change log
cd gamecode\%AB%
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. Aborting.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed Aborting Reset." >nul 2>nul
del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Reset finished. Reset will take place next round." >nul 2>nul
echo Done. The Reset will automatically take place at round restart.
timeout 300

View File

@@ -1,19 +0,0 @@
@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 15 seconds.
timeout 15
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 minibot.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

@@ -1,39 +0,0 @@
@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 30 seconds.
timeout 30
if not exist gamedata\data\logs\runtimes mkdir gamedata\data\logs\runtimes\
@call python bot\nudge.py "WATCHDOG" "Watch Dog online. Starting server" >nul 2>nul
:START
call bin\getcurdate.bat
call bin\getunixtime.bat UNIXTIME
echo %UNIXTIME%
set STARTTIME=%UNIXTIME%
cls
echo Watch Dog.
echo Server Running. Watching for server exits.
start /WAIT /ABOVENORMAL "" dreamdaemon.exe gamefolder\%PROJECTNAME%.dmb -port %PORT% -trusted -close -public -verbose
cls
call bin\getunixtime.bat UNIXTIME
SET /A Result=%UNIXTIME% - %STARTTIME%
SET /A Result=180 - (%Result%/3)
if %Result% LSS 0 set /A Result=0
echo Watch Dog.
echo Server exit detected. Restarting in %Result% seconds.
@python bot\nudge.py "WATCHDOG" "Server exit detected. Restarting server in %Result% seconds." >nul 2>nul
timeout %Result%
goto :START

View File

@@ -1,99 +0,0 @@
@echo off
title Server Updater
SETLOCAL ENABLEDELAYEDEXPANSION
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 prtestjob.lk (
call bin/activepr.bat
echo WARNING: The server is currently testing the following PRs !PR!. This update would override that. Do you still want to update? Close this window if not, otherwise:
pause
)
del /F /Q prtestjob.lk >nul 2>nul
echo lock>updating.lk
<nul set /p TRIM="set PR=" > bin/activepr.bat
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"
call 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
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git fetch failed. Aborting update"
del updating.lk >nul 2>nul
pause
exit /b 1
)
if defined PUSHCHANGELOGTOGIT (
cd gitrepo
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, [ci skip]"
if !ERRORLEVEL! == 0 (
git push
)
REM an error here generally means there was nothing to commit.
)
cd ..
)
echo ##################################
echo ##################################
echo:
echo Updating done, compiling in 10 seconds. If you want to preform other actions (like test merge) You can close this now and do them.
echo:
del updating.lk >nul 2>nul
timeout 10
echo lock>updating.lk
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 Compiling game.
call bin\build.bat
if %DM_EXIT% neq 0 (
echo DM compile failed. Aborting.
call 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
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call 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

@@ -1,121 +0,0 @@
@echo off
title Server Updater
SETLOCAL ENABLEDELAYEDEXPANSION
set HOME = %USERPROFILE%
call config.bat
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"
call bin\getcurdate.bat
call bin\findgit.bat
echo This will handle Resetting the repo downloading from git, merging the pr locally, compiling the server, and applying the PR test job.
:PROMPT
SET /P UserInput=Please enter the pr number (without a # or anything of the sorts):
SET /A PR=UserInput
if %PR% EQU %UserInput% (
if %PR% GTR 0 (
echo updating to pr %PR%
) else (
echo Bad input
goto PROMPT
)
) else (
echo Bad input
goto PROMPT
)
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
)
echo lock>updating.lk
<nul set /p TRIM="set PR=" > bin/activepr.bat
del /F /Q prtestjob.lk >nul 2>nul
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "PR test job started. Updating master and merging PR #%PR% locally" >nul 2>nul
call bin\updategit.bat
if %GIT_EXIT% neq 0 (
echo git pull failed. Aborting update
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git fetch failed. Aborting update"
del updating.lk >nul 2>nul
pause
exit /b 1
)
if defined PUSHCHANGELOGTOGIT (
cd gitrepo
echo compiling change log
call 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, [ci skip]"
if !ERRORLEVEL! == 0 (
git push
)
REM an error here generally means there was nothing to commit.
)
cd ..
)
cd gitrepo
git fetch -f origin pull/%PR%/head:pr-%PR%
git merge pr-%PR%
if %ERRORLEVEL% neq 0 (
git reset --hard
git clean -fd
cd ..
echo git merge of PR #%PR% failed. Aborting test merge.
echo An update was successfully preformed but not applied, if you want you can apply it by running recompile.bat
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "git merge of PR #%PR% failed. Aborting PR test job" >nul 2>nul
del updating.lk >nul 2>nul
pause
exit /b 1
)
cd ..
echo %PR%>prtestjob.lk
<nul set /p TRIM=%PR% >> bin/activepr.bat
echo ##################################
echo ##################################
echo:
echo Updating to pr done, compiling in 10 seconds. If you want to preform other actions (like more test merges) You can close this now and do them.
echo:
del updating.lk >nul 2>nul
timeout 10
echo lock>updating.lk
call bin\findab.bat
call bin\copyfromgit.bat
echo compiling change log (again)
cd gamecode\%AB%
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. Aborting.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed. Aborting test merge." >nul 2>nul
del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Test merge job finished. Test merge will take place next round." >nul 2>nul
echo Done. The test merge will automatically take place at round restart.
timeout 300

View File

@@ -1,100 +0,0 @@
@echo off
@title Server Updater
SETLOCAL ENABLEDELAYEDEXPANSION
set HOME = %USERPROFILE%
call config.bat
call bin\getcurdate.bat
call bin\findgit.bat
echo This will update the server without resetting local changes like test merges.
echo Note: This doesn't update the changelog like a normal update does.
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
)
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"
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Update job started (No reset mode)" >nul 2>nul
cd gitrepo
git fetch origin
if %ERRORLEVEL% neq 0 (
cd ..
echo git fetch failed. Aborting update.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git fetch failed. Aborting update"
del updating.lk >nul 2>nul
pause
exit /b 1
)
git merge origin/%REPO_BRANCH%
if %ERRORLEVEL% neq 0 (
cd ..
echo git merge of upstream master failed, aborting update.
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "git merge of upstream master failed, aborting update." >nul 2>nul
cd gitrepo
git merge --abort
if %ERRORLEVEL% neq 0 (
echo ERROR: Error aborting update, resetting repo.
cd ..
call python bot\nudge.py %UPDATE_LOG_CHANNEL% "Error aborting merge, Resetting git repo" >nul 2>nul
cd gitrepo
git reset --hard
git clean -fd
<nul set /p TRIM="set PR=" > bin/activepr.bat
del /F /Q prtestjob.lk >nul 2>nul
echo NOTICE: We had to reset the repo's state, all active test merges were undone.
)
cd ..
del updating.lk >nul 2>nul
pause
exit /b 1
)
cd ..
echo ##################################
echo ##################################
echo:
echo In place update done, compiling in 10 seconds. If you want to preform other actions (like more test merges) You can close this now and do them.
echo:
del updating.lk >nul 2>nul
timeout 10
echo lock>updating.lk
call bin\findab.bat
call bin\copyfromgit.bat
echo compiling change log
cd gamecode\%AB%
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. Aborting.
call 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
)
del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
call 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

@@ -1 +0,0 @@
set PR=

View File

@@ -1,26 +0,0 @@
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%
echo #define PUTONHUB 1 >>%MDME_LOCATION%
type %DME_LOCATION% >>%MDME_LOCATION%
dm -clean %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

@@ -1,20 +0,0 @@
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
del /q gamecode\%AB%\nudge.py >nul 2>nul
del /q gamecode\%AB%\libmysql.dll >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
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 gamecode\%AB%\libmysql.dll ..\..\gamedata\libmysql.dll >nul

View File

@@ -1,45 +0,0 @@
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.
if exist gamecode\b\%PROJECTNAME%.rsc.lk (
rem we attempt to delete the lock file to see if the server is currently running.
del /q gamecode\b\%PROJECTNAME%.rsc.lk >nul 2>nul
if exist gamecode\b\%PROJECTNAME%.rsc.lk set RUNNING=1
rmdir /q gamefolder
mklink /d gamefolder gamecode\b >nul
echo Game is in actually currently running on the "B" folder, Resetting current folder to the "B" folder first
)
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.
if exist gamecode\a\%PROJECTNAME%.rsc.lk (
rem we attempt to delete the lock file to see if the server is currently running.
del /q gamecode\a\%PROJECTNAME%.rsc.lk >nul 2>nul
if exist gamecode\a\%PROJECTNAME%.rsc.lk set RUNNING=1
rmdir /q gamefolder
mklink /d gamefolder gamecode\a >nul
echo Game is in actually currently running on the "A" folder, Resetting current folder to the "A" folder first
)
set AB=b
)
)
del gamefolder\updater.temp >nul 2>nul

View File

@@ -1,26 +0,0 @@
@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

@@ -1,31 +0,0 @@
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

@@ -1,2 +0,0 @@
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

@@ -1,12 +0,0 @@
REM setlocal
call :GetUnixTime UNIXTIME
goto :EOF
:GetUnixTime
REM setlocal enableextensions
for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do (
set %%x)
set /a z=(14-100%Month%%%100)/12, y=10000%Year%%%10000-z
set /a ut=y*365+y/4-y/100+y/400+(153*(100%Month%%%100+12*z-3)+2)/5+Day-719469
set /a ut=ut*86400+100%Hour%%%100*3600+100%Minute%%%100*60+100%Second%%%100
endlocal & set "%1=%ut%" & goto :EOF

View File

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

View File

@@ -1,12 +0,0 @@
call bin\findgit.bat
echo Updating repo
cd gitrepo
git branch backup-%CUR_DATE% >nul 2>nul
git fetch
set GIT_EXIT=%ERRORLEVEL%
git reset origin/%REPO_BRANCH% --hard
cd ..

View File

@@ -1,42 +0,0 @@
@echo off
REM Server Tools configuration file. Lines starting with rem are comments and ignored.
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. (use an ssh url if you plan to push compiled changlogs)
REM Only set during install, do not re-run install.bat if you change this, instead manually change the remote of the gitrepo folder using git tools
set REPO_URL=https://github.com/tgstation/-tg-station.git
REM What branch of the repo to use.
set REPO_BRANCH=master
REM Override Map (This disables map roation and forces the selected map to always be loaded)
REM set MAPFILE=tgstation2
REM set MAPFILE=metastation
REM port to use when starting the server
set PORT=2337
REM This is the channel to log updates to. Leave blank to log to the bot's default logging channel (this is done via the tgstation minibot bot, optional)
set UPDATE_LOG_CHANNEL=#devbus,#coderbus,#tgstation13
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. (git for windows users should just put an ssh key in c:\users\USERNAME_HERE\.ssh\ as the filename id_rsa) And you should have installed this with a git, ssh, or file url)
set PUSHCHANGELOGTOGIT=
REM location of git. The script will attempt to auto detect this, but if it fails, you can set it manually.
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\Administrator\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin;C:\Users\Administrator\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\cmd
REM path to the byond bin folder. (same rules as git path above, almost always auto detected, but you could point this to the output of the zip version for install-less setups, and even abuse that to make updating byond versions less of a pain by just changing this config and then crashing the server.)
set BYOND_LOCATION_PATH=

View File

@@ -1,9 +0,0 @@
//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\.git\
gitrepo\libmysql.dll

View File

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

View File

@@ -1,81 +0,0 @@
@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 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\bot bot /Y /X /K /R /H /I /C /V /E /Q >nul
copy gitrepo\libmysql.dll gamedata\libmysql.dll /D /V /Y >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\libmysql.dll ..\..\gamedata\libmysql.dll
mklink /d gamecode\a\data ..\..\gamedata\data
mklink /d gamecode\a\config ..\..\gamedata\config
mklink gamecode\b\nudge.py ..\..\bot\nudge.py
mklink gamecode\b\libmysql.dll ..\..\gamedata\libmysql.dll
mklink /d gamecode\b\data ..\..\gamedata\data
mklink /d gamecode\b\config ..\..\gamedata\config
mklink /d gamefolder gamecode\a
echo prepping python (if installed)
pip install PyYaml
pip install beautifulsoup4
echo Compiling for the first time.
echo Compiling change log.
cd gamefolder
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