This repository has been archived by the owner on Oct 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKernel.bat
176 lines (163 loc) · 4.67 KB
/
Kernel.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
@echo off
setlocal
if "%selfWrapped%"=="" (
REM this is necessary so that we can use "exit" to terminate the batch file,
REM and all subroutines, but not the original cmd.exe
set selfWrapped=true
%ComSpec% /s /c ""%~0" %*"
if /i not "%cmdcmdline:"=%" == "%ComSpec%" pause
goto :eof
)
set "arg=%1"
if "%arg%" == "-h" goto :help
if "%arg%" == "--help" goto :help
if "%arg%" == "/h" goto :help
if "%arg%" == "/?" goto :help
for /f "tokens=* usebackq" %%F in (`powershell -noprofile -c "[Console]::Title.Replace(' - %0','') -replace '(.+) - .+'"`) do set "initialTitle=%%F"
set "title=Kernel Installer - %initialTitle%"
title %title%
set initialDirectory=%cd%
set kernelasarDirectory=%~dp0Kernel
if not exist %kernelasarDirectory% mkdir %kernelasarDirectory%
cd %kernelasarDirectory%
call :discord-release & echo.
if not "%errorlevel%"=="0" goto :end
if not exist git\ mkdir git\
cd git\
call :browser & echo.
if not "%errorlevel%"=="0" goto :end
call :electron & echo.
if not "%errorlevel%"=="0" goto :end
call :installer & echo.
if not "%errorlevel%"=="0" goto :end
cd ..
call :install & echo.
if not "%errorlevel%"=="0" goto :end
call :optional-packages & echo.
if not "%errorlevel%"=="0" goto :end
goto :end
:browser
echo Updating the browser repository...
if exist browser\.git\ (
cd browser
call git reset --hard
call git pull --force
cd ..
) else (
rmdir /s /q browser >nul 2>&1
call git clone https://github.com/kernel-mod/browser.git browser
)
cd browser
call pnpm i
cd ..
goto :eof
:electron
echo Updating the electron repository...
if exist electron\.git\ (
cd electron
call git reset --hard
call git pull --force
cd ..
) else (
rmdir /s /q electron >nul 2>&1
call git clone https://github.com/kernel-mod/electron.git electron
)
cd electron
call pnpm i
echo.
echo Building Kernel...
call pnpm run build
cd ..
goto :eof
:installer
echo Updating installer...
if exist kernel-installer.exe (
del kernel-installer.exe
)
curl -L -o kernel-installer.exe https://github.com/kernel-mod/installer-cli/releases/download/refs/heads/master/kernel-installer-x86_64-windows.exe
goto :eof
:install
tasklist | find /i "discord%discord%" >nul && (
echo Killing Discord %discord%
taskkill /f /im Discord%discord%.exe
echo.
set "wasOpen=true"
echo Discord will launch again when finished.
)
cd /D %localappdata%\Discord%discord%\app*
timeout 2>nul & REM very good solution
if exist resources\app\ (
cd resources
rmdir /s /q app\
rename app-original.asar app.asar
cd ..
)
call %kernelasarDirectory%\git\kernel-installer.exe -i . -k %kernelasarDirectory%
move %kernelasarDirectory%\git\electron\dist\kernel.asar %kernelasarDirectory%
if not exist %kernelasarDirectory%\Packages mkdir %kernelasarDirectory%\Packages
if "%wasOpen%"=="true" (
echo Starting Discord %discord%
call %localappdata%\Discord%discord%\Update.exe --processStart Discord%discord%.exe
)
cd /D %kernelasarDirectory%
goto :eof
:optional-packages
choice /C YN /T 10 /D N /N /M "Would you like to install some optional packages? (y/N)"
if %errorlevel% equ 1 (
set errorlevel=0
set "user=strencher-kernel" & set "package=settings" & call :kernel-package
set "user=strencher-kernel" & set "package=bd-compat" & call :kernel-package
set "user=strencher-kernel" & set "package=pc-compat" & call :kernel-package
set "user=discord-modifications" & set "package=discord-utilities" & call :kernel-package
echo Finishing up
forfiles /c "cmd /c if @isdir==TRUE (if exist @file\package.json (if not exist @file\node_modules\ (cd @file && echo @path & pnpm i & cd ..)))"
echo Discord needs to be relaunched/reloaded for these changes to take effect.
)
goto :eof
:kernel-package
echo Installing %package%
pushd
cd %kernelasarDirectory%\Packages
if not exist %package% (
call git clone https://github.com/%user%/%package%.git
) else (
cd %package%
call git reset --hard
call git pull --force
cd ..
)
popd
echo.
goto :eof
:discord-release
if not [%arg%]==[] (set "discord=%arg%") else (
echo S = Stable
echo P = PTB
echo C = Canary
echo D = Development
set /p discord="Discord Release: "
)
if /i %discord%==S ( set "discord="
) else if /i %discord%==Stable ( set "discord="
) else if /i %discord%==P ( set "discord=PTB"
) else if /i %discord%==C ( set "discord=Canary"
) else if /i %discord%==D ( set "discord=Development"
) else if /i %discord%==Dev ( set "discord=Development"
) else (
echo Invalid release channel.
set errorlevel=1
goto :eof
)
goto :eof
:help
echo You can set a singular argument to select a release channel.
echo "%cd:"=%\%~0" Stable
echo.
endlocal
exit /b
:end
echo Finished. Err: %errorlevel%
cd /D %initialDirectory%
title %initialTitle%
endlocal
exit /b %errorlevel%