forked from rafradek/sigsegv-mvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows_install_wsl.bat
129 lines (112 loc) · 6.24 KB
/
windows_install_wsl.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@echo off
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
powershell -Command Get-ComputerInfo -property "HyperVisorPresent" | find /i "True"
if not errorlevel 1 (
) else (
powershell -Command Get-ComputerInfo -property "HyperVRequirementVirtualizationFirmwareEnabled" | find /i "True"
if errorlevel 1 (
echo "Hardware Virtualization is disabled. Enable it in BIOS settings and try again"
pause
exit
)
)
mkdir TF2Server
cd TF2Server
(
echo @echo off
echo cd /d "%%~dp0"
echo echo Setting default wsl version to 2
echo wsl --set-default-version 2
echo echo wait 30 seconds
echo timeout 30 /nobreak
echo echo -
echo echo ----------------------
echo echo Installing ubuntu
echo echo ----------------------
echo ubuntu install --root
echo echo -
echo echo ----------------------
echo echo Installing packages
echo echo ----------------------
echo wsl -d ubuntu -u root dpkg --add-architecture i386
echo wsl -d ubuntu -u root apt-get update
echo wsl -d ubuntu -u root apt-cache --generate pkgnames ^| grep --line-regexp --fixed-strings -e unzip -e lib32z1 -e libncurses5:i386 -e libbz2-1.0:i386 -e lib32gcc1 -e lib32stdc++6 -e libtinfo5:i386 -e libcurl3-gnutls:i386 ^| xargs apt install -y
echo wsl -d ubuntu -u root apt install -y unzip lib32z1 libncurses5:i386 libbz2-1.0:i386 lib32gcc1 lib32stdc++6 libtinfo5:i386 libcurl3-gnutls:i386
echo wsl -d ubuntu -u root ufw disable
echo echo -
echo echo ----------------------
echo echo Installing game server
echo echo ----------------------
echo wsl -d ubuntu -u root mkdir -p /var/tf2server
echo wsl -d ubuntu -u root useradd -m gameserver
echo wsl -d ubuntu -u root chown -R gameserver:gameserver /var/tf2server
echo wsl -d ubuntu -u gameserver cd /var/tf2server; wget "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz"; tar zxf steamcmd_linux.tar.gz; ./steamcmd.sh +force_install_dir ./tf +login anonymous +app_update 232250 +quit
echo echo -
echo echo ----------------------
echo echo Installing Sourcemod
echo echo ----------------------
echo echo Installing Metamod
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl https://mms.alliedmods.net/mmsdrop/1.11/`curl https://mms.alliedmods.net/mmsdrop/1.11/mmsource-latest-linux` -o metamod.tar.gz; tar -xf metamod.tar.gz -C ./tf/tf/;
echo echo Installing Sourcemod
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl https://sm.alliedmods.net/smdrop/1.11/`curl https://sm.alliedmods.net/smdrop/1.11/sourcemod-latest-linux` -o sourcemod.tar.gz; tar -xf sourcemod.tar.gz -C ./tf/tf/;
echo echo Installing Sigsegv-MvM extension
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl -LJ https://github.com/rafradek/sigsegv-mvm/releases/latest/download/package-linux.zip -o package-linux.zip; unzip -d ./tf/tf/ package-linux.zip;
echo echo -
echo echo ----------------------
echo echo INSTALLATION COMPLETE!
echo echo ----------------------
echo echo To run the game server, enter the newly created TF2Server directory and run the Run Server.bat file
echo pause
echo start /b "" cmd /c del "%%~f0"^&exit /b
echo exit
) > "SetupSigsegvAfterBoot.bat"
echo SET port=27015> "Run Server.bat"
echo FOR /F "tokens=* USEBACKQ" %%%%F IN (`wsl hostname -I`) DO (>> "Run Server.bat"
echo SET ip=%%%%F>> "Run Server.bat"
echo )>> "Run Server.bat"
echo start /b %%~dp0\sudppipe\sudppipe.exe -q -b 0.0.0.0 %%ip%% %%port%% %%port%%>> "Run Server.bat"
echo wsl -d ubuntu -u gameserver cd /var/tf2server; ./steamcmd.sh +force_install_dir ./tf +login anonymous +app_update 232250 +quit>> "Run Server.bat"
echo wsl -d ubuntu -u gameserver /var/tf2server/tf/srcds_run +map bigrock +maxplayers 32 -port %%port%% -address 0.0.0.0>> "Run Server.bat"
echo wmic process where "commandline like '%%%%-q -b 0.0.0.0 %%%%ip%% %%port%% %%port%%%%'" delete>> "Run Server.bat"
(
echo echo Installing Metamod
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl https://mms.alliedmods.net/mmsdrop/1.11/`curl https://mms.alliedmods.net/mmsdrop/1.11/mmsource-latest-linux` -o metamod.tar.gz; tar -xf metamod.tar.gz -C ./tf/tf/;
echo echo Installing Sourcemod
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl https://sm.alliedmods.net/smdrop/1.11/`curl https://sm.alliedmods.net/smdrop/1.11/sourcemod-latest-linux` -o sourcemod.tar.gz; tar -xf sourcemod.tar.gz -C ./tf/tf/ --exclude "addons/sourcemod/configs" --exclude "cfg";
echo echo Installing Sigsegv-MvM extension
echo wsl -d ubuntu -u gameserver cd /var/tf2server; curl -LJ https://github.com/rafradek/sigsegv-mvm/releases/latest/download/package-linux.zip -o package-linux.zip; unzip -o -x "cfg/*" -d ./tf/tf/ package-linux.zip;
echo echo Update complete
) > "Update Server.bat"
(
echo wsl -d ubuntu -u gameserver cd /var/tf2server/tf; explorer.exe .
) > "Browse Files.bat"
echo choice /C YN /M "Do you want to delete the linux VM and all server files ? [Y/N]"> "Delete Server.bat"
echo if errorlevel 2 (>> "Delete Server.bat"
echo Server files are not deleted>> "Delete Server.bat"
echo ) else (>> "Delete Server.bat"
echo wsl --unregister ubuntu>> "Delete Server.bat"
echo cd ..>> "Delete Server.bat"
echo rmdir /q /s TF2Server>> "Delete Server.bat"
echo )>> "Delete Server.bat"
curl http://aluigi.altervista.org/mytoolz/sudppipe.zip > sudppipe.zip
powershell -Command Expand-Archive -Force sudppipe.zip sudppipe
if not exist "%windir%\System32\bash.exe" (
wsl --install -d ubuntu
echo [wsl2] > %USERPROFILE%/.wslconfig
echo memory=2GB >> %USERPROFILE%/.wslconfig
reg add HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /f /v "WslInstallContinue" /t REG_SZ /d "%COMSPEC% /c """%cd%\SetupSigsegvAfterBoot.bat"""
echo -------------
echo -------------
echo Reboot system to continue installation
choice /C YN /M "Do you want to reboot the system now?"
if errorlevel 2 (
echo Reboot the system later to continue
) else (
shutdown -r -t 0
)
pause
) else (
SetupSigsegvAfterBoot.bat
)
exit