Advertisement
Guest User

SquadServer.bat

a guest
Jun 15th, 2017
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.99 KB | None | 0 0
  1. @ECHO OFF
  2. :: Created by [173rd]D.Dodson for the 173rd Airborne Brigade - 173rd.us"
  3. :: Myself and the 173rd are not liable for data loss. It should not happen with this script but with technology it may. You use this at your own risk.
  4. :: Last revised 06/13/2017 @ 4:59 PM
  5. :: Revision 1.0.0
  6. :: Changes - Designed challenges prior to system changes for public release
  7. :: Needed - 1: A lot more tacos in my life
  8.  
  9. :adminCheck
  10.     SET BatDirectory=%~dp0
  11.     NET FILE 1>NUL 2>NUL
  12.     if '%errorlevel%' == '0' ( goto challenge ) else ( goto getPrivileges )
  13.  
  14. :getPrivileges
  15.     if '%1'=='ELEV' (shift & goto challenge )  
  16.     setlocal DisableDelayedExpansion
  17.     set "batchPath=%~0"
  18.     setlocal EnableDelayedExpansion
  19.     ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
  20.     ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
  21.     "%temp%\OEgetPrivileges.vbs"
  22.     EXIT /B
  23.  
  24. :challenge
  25.     CLS
  26.     TITLE Squad Server Creator by [173rd]D.Dodson for the 173rd Airborne Brigade - 173rd.us
  27.     ECHO ############################################################################
  28.     ECHO #                 173rd Airborne Brigade Squad Server Creator              #
  29.     ECHO #                        Created by [173rd]D.Dodson                        #
  30.     ECHO #                               Version 1.0.0                              #
  31.     ECHO #                 This will setup the Squad server for you.                #
  32.     ECHO #                                                                          #
  33.     ECHO #              Please ensure you have the following installed:             #
  34.     ECHO #                       1: DirectX End-User Runtimes                       #
  35.     ECHO #       2: Visual C++ Redistributable for Visual Studio 2013 and 2015      #
  36.     ECHO #                                                                          #
  37.     ECHO #      WARNING: NOT responsible for data loss - use at your own risk       #
  38.     ECHO ############################################################################
  39.     ECHO Do you want to continue?
  40.     ECHO.
  41.     SET /P c=Please make your choice[Y/N]?
  42.     IF /I "%c%" EQU "Y" GOTO :serverSetup
  43.     IF /I "%c%" EQU "y" GOTO :serverSetup
  44.     IF /I "%c%" EQU "N" GOTO :exit
  45.     IF /I "%c%" EQU "n" GOTO :exit
  46.     GOTO :challenge
  47.  
  48. :serverSetup
  49.     CLS
  50.     TITLE Installing Squad Server
  51.     ECHO What instance number of server is this?
  52.     ECHO Please enter a number like 1,2,3,etc
  53.     SET /P Instance=Please enter your choice:
  54.     SET SquadDir="C:\Games\Squad"
  55.     ECHO.
  56.     ECHO What is the max numbers of players allowed? (Most use 80)
  57.     SET /P Players=Number of Players:
  58.     ECHO.
  59.     ECHO What is the IP Address to listen on? (0.0.0.0 for single homed servers)
  60.     SET /P IP=IP Address:
  61.     ECHO.
  62.     ECHO What port do you wish to listen on? (Default is 7787)
  63.     SET /P Port1=Listening Port:
  64.     ECHO.
  65.     ECHO What port do you wish to query on? (Default is 27165)
  66.     SET /P Port2=Query Port:
  67.     ECHO.
  68.     CLS
  69.     ECHO ######################################################################
  70.     ECHO **********  CHANGES ARE ABOUT TO BE COMMITED TO THE SYSTEM  **********
  71.     ECHO ######################################################################
  72.     ECHO.
  73.     ECHO Do you wish to continue?
  74.     SET /P continue=Please make your choice[Y/N]?
  75.     IF /I "%continue%" EQU "Y" GOTO :folders
  76.     IF /I "%continue%" EQU "y" GOTO :folders
  77.     IF /I "%continue%" EQU "N" GOTO :exit
  78.     IF /I "%continue%" EQU "n" GOTO :exit
  79.     GOTO :challenge
  80.    
  81. :folders
  82.     CLS
  83.     TITLE Creating folder requirements for Squad Server
  84.     IF NOT EXIST C:\Apps MKDIR C:\Apps & cacls C:\Apps /e /g Users:F & cacls C:\Apps /e /g Administrators:F & cacls C:\Apps /e /g System:F
  85.     IF NOT EXIST C:\Apps\Temp MKDIR C:\Apps\Temp & cacls C:\Apps\Temp /e /g Users:F & cacls C:\Apps\Temp /e /g Administrators:F & cacls C:\Apps\Temp /e /g System:F
  86.     IF NOT EXIST C:\Games MKDIR C:\Games & cacls C:\Games /e /g Users:F & cacls C:\Games /e /g Administrators:F & cacls C:\Games /e /g System:F
  87.     IF NOT EXIST C:\Games\Squad MKDIR C:\Games\Squad & cacls C:\Games\Squad /e /g Users:F & cacls C:\Games\Squad /e /g Administrators:F & cacls C:\Games\Squad /e /g System:F
  88.     CLS
  89.     GOTO download
  90.    
  91. :download
  92.     CLS
  93.     TITLE Dowloading requirements for Squad Server
  94.     SET wget="C:\Apps\wget.exe"
  95.     SET AppsDir="C:\Apps"
  96.     SET TempDir="C:\Apps\Temp"
  97.     bitsadmin.exe /transfer "WGET_Download" https://s3-us-west-2.amazonaws.com/gameserverrequirements/wget.exe C:\Apps\wget.exe
  98.     %WGET% --no-check-certificate -P %TempDir% https://s3-us-west-2.amazonaws.com/gameserverrequirements/7za.exe
  99.     %WGET% --no-check-certificate -P %TempDir% https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
  100.     DEL %WGET%
  101.     CLS
  102.     GOTO extract
  103.    
  104. :extract
  105.     CLS
  106.     TITLE Extracting downloaded requirements for Squad Server
  107.     cd %tempDir%
  108.     7za.exe x steamcmd.zip
  109.     MOVE steamcmd.exe %AppsDir%\steamcmd.exe
  110.     DEL /S /Q steamcmd.zip
  111.     DEL /S /Q 7za.exe
  112.     DEL /S /Q _start-example.bat
  113.     DEL /S /Q _start-example.sh
  114.     CD %appsDir%
  115.     CLS
  116.     GOTO continue
  117.    
  118. :continue
  119.     IF NOT EXIST Server%Instance% MKDIR %SquadDir%\Server%Instance% & cacls %SquadDir%\Server%Instance% /e /g Users:F & cacls %SquadDir%\Server%Instance% /e /g Administrators:F & cacls %SquadDir%\Server%Instance% /e /g System:F
  120.     SET ServerDir="%SquadDir%\Server%Instance%"
  121.     %AppsDir%\steamcmd.exe +login anonymous +force_install_dir %ServerDir% +app_update 403240 + validate +quit
  122.     CLS
  123.     CD %ServerDir%
  124.     netsh advfirewall firewall add rule name="Squad Server - Server%Instance%" dir=in action=allow program="C:\Games\Squad\Server%Instance%\Squad\Binaries\Win64\SquadServer.exe" enable=yes
  125.     TITLE Configuring Squad Server
  126.     CLS
  127.     ECHO START SquadServer.exe MULTIHOME=%IP% Port=%Port1% QueryPort=%Port2% FIXEDMAXPLAYERS=%Players% RANDOM=ALWAYS -log >> StartSquadServer%Instance%.bat
  128.     CLS
  129.     ECHO SquadServer install complete. Next Steps...
  130.     ECHO 1: Move your config files into %SquadDir%\Server%Instance%\Squad\ServerConfig
  131.     ECHO 2: Start the server with the file %SquadDir%\Server%Instance%\StartSquadServer%Instance%.bat
  132.     PAUSE
  133.     GOTO exit
  134.    
  135.    
  136. :exit
  137.     exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement