2016-11-30 12:02:30 +00:00
|
|
|
@ECHO off
|
2017-01-30 01:17:49 +00:00
|
|
|
TITLE Downloading Latest Build of NadekoBot...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Setting convenient to read variables which don't delete the windows temp folder
|
2017-03-13 05:15:51 +00:00
|
|
|
SET "root=%~dp0"
|
|
|
|
CD /D "%root%"
|
|
|
|
SET "rootdir=%cd%"
|
|
|
|
SET "build1=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Core\"
|
|
|
|
SET "build2=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Rest\"
|
|
|
|
SET "build3=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.WebSocket\"
|
|
|
|
SET "build4=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Commands\"
|
|
|
|
SET "build5=%root%NadekoInstall_Temp\NadekoBot\src\NadekoBot\"
|
|
|
|
SET "installtemp=%root%NadekoInstall_Temp\"
|
2016-11-30 12:02:30 +00:00
|
|
|
::Deleting traces of last setup for the sake of clean folders, if by some miracle it still exists
|
2017-03-13 05:15:51 +00:00
|
|
|
IF EXIST "%installtemp%" ( RMDIR "%installtemp%" /S /Q >nul 2>&1)
|
|
|
|
timeout /t 5
|
2016-11-30 12:02:30 +00:00
|
|
|
::Checks that both git and dotnet are installed
|
|
|
|
dotnet --version >nul 2>&1 || GOTO :dotnet
|
|
|
|
git --version >nul 2>&1 || GOTO :git
|
|
|
|
::Creates the install directory to work in and get the current directory because spaces ruins everything otherwise
|
|
|
|
:start
|
2017-03-13 05:15:51 +00:00
|
|
|
MKDIR "%root%NadekoInstall_Temp"
|
|
|
|
CD /D "%installtemp%"
|
2016-11-30 12:02:30 +00:00
|
|
|
::Downloads the latest version of Nadeko
|
|
|
|
ECHO Downloading Nadeko...
|
|
|
|
ECHO.
|
|
|
|
git clone -b dev --recursive --depth 1 --progress https://github.com/Kwoth/NadekoBot.git >nul
|
|
|
|
IF %ERRORLEVEL% EQU 128 (GOTO :giterror)
|
2017-01-30 01:17:49 +00:00
|
|
|
TITLE Installing NadekoBot, please wait...
|
2016-11-30 12:02:30 +00:00
|
|
|
ECHO.
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO Installing Discord.Net(1/4)...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Building Nadeko
|
2017-03-13 05:15:51 +00:00
|
|
|
CD /D "%build1%"
|
2016-11-30 12:02:30 +00:00
|
|
|
dotnet restore >nul 2>&1
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO Installing Discord.Net(2/4)...
|
2017-03-13 05:15:51 +00:00
|
|
|
CD /D "%build2%"
|
2016-11-30 12:02:30 +00:00
|
|
|
dotnet restore >nul 2>&1
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO Installing Discord.Net(3/4)...
|
2017-03-13 05:15:51 +00:00
|
|
|
CD /D "%build3%"
|
2016-11-30 12:02:30 +00:00
|
|
|
dotnet restore >nul 2>&1
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO Installing Discord.Net(4/4)...
|
2017-03-13 05:15:51 +00:00
|
|
|
CD /D "%build4%"
|
2017-01-02 08:43:56 +00:00
|
|
|
dotnet restore >nul 2>&1
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO.
|
|
|
|
ECHO Discord.Net installation completed successfully...
|
|
|
|
ECHO.
|
|
|
|
ECHO Installing NadekoBot...
|
2017-03-13 05:15:51 +00:00
|
|
|
CD /D "%build5%"
|
2017-01-02 08:43:56 +00:00
|
|
|
dotnet restore >nul 2>&1
|
2016-11-30 12:02:30 +00:00
|
|
|
dotnet build --configuration Release >nul 2>&1
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO.
|
|
|
|
ECHO NadekoBot installation completed successfully...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Attempts to backup old files if they currently exist in the same folder as the batch file
|
2017-03-13 05:15:51 +00:00
|
|
|
IF EXIST "%root%NadekoBot\" (GOTO :backupinstall) ELSE (GOTO :freshinstall)
|
2016-11-30 12:02:30 +00:00
|
|
|
:freshinstall
|
|
|
|
::Moves the NadekoBot folder to keep things tidy
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO.
|
|
|
|
ECHO Moving files, Please wait...
|
2016-11-30 12:02:30 +00:00
|
|
|
ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
2017-01-30 01:17:49 +00:00
|
|
|
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
|
2016-11-30 12:02:30 +00:00
|
|
|
:backupinstall
|
2017-01-30 01:17:49 +00:00
|
|
|
TITLE Backing up old files...
|
|
|
|
ECHO.
|
|
|
|
ECHO Moving and Backing up old files...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Recursively copies all files and folders from NadekoBot to NadekoBot_Old
|
|
|
|
ROBOCOPY "%root%NadekoBot" "%root%NadekoBot_Old" /MIR >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
|
|
|
ECHO.
|
2017-03-04 20:47:28 +00:00
|
|
|
ECHO Old files backed up to NadekoBot_Old...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Copies the credentials and database from the backed up data to the new folder
|
|
|
|
COPY "%root%NadekoBot_Old\src\NadekoBot\credentials.json" "%installtemp%NadekoBot\src\NadekoBot\credentials.json" >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
|
|
|
ECHO.
|
2017-03-04 20:47:28 +00:00
|
|
|
ECHO credentials.json copied...
|
2016-11-30 12:02:30 +00:00
|
|
|
ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\bin" "%installtemp%NadekoBot\src\NadekoBot\bin" /E >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
|
|
|
ECHO.
|
2017-03-04 20:47:28 +00:00
|
|
|
ECHO bin folder copied...
|
2017-03-04 22:04:35 +00:00
|
|
|
RD /S /Q "%root%NadekoBot_Old\src\NadekoBot\data\musicdata"
|
2017-03-04 20:47:28 +00:00
|
|
|
ECHO.
|
|
|
|
ECHO music cache cleared...
|
2016-11-30 12:02:30 +00:00
|
|
|
ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\data" "%installtemp%NadekoBot\src\NadekoBot\data" /E >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
|
|
|
ECHO.
|
2017-03-04 22:04:35 +00:00
|
|
|
ECHO Old data folder copied...
|
2016-11-30 12:02:30 +00:00
|
|
|
::Moves the setup Nadeko folder
|
|
|
|
RMDIR "%root%NadekoBot\" /S /Q >nul 2>&1
|
|
|
|
ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
|
|
|
|
IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
|
2017-01-30 01:17:49 +00:00
|
|
|
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
|
2016-11-30 12:02:30 +00:00
|
|
|
:dotnet
|
|
|
|
::Terminates the batch script if it can't run dotnet --version
|
|
|
|
TITLE Error!
|
|
|
|
ECHO dotnet not found, make sure it's been installed as per the guides instructions!
|
|
|
|
ECHO Press any key to exit.
|
|
|
|
PAUSE >nul 2>&1
|
|
|
|
CD /D "%root%"
|
|
|
|
GOTO :EOF
|
|
|
|
:git
|
|
|
|
::Terminates the batch script if it can't run git --version
|
|
|
|
TITLE Error!
|
|
|
|
ECHO git not found, make sure it's been installed as per the guides instructions!
|
|
|
|
ECHO Press any key to exit.
|
|
|
|
PAUSE >nul 2>&1
|
|
|
|
CD /D "%root%"
|
|
|
|
GOTO :EOF
|
|
|
|
:giterror
|
|
|
|
ECHO.
|
|
|
|
ECHO Git clone failed, trying again
|
2017-03-13 05:15:51 +00:00
|
|
|
RMDIR "%installtemp%" /S /Q >nul 2>&1
|
2016-11-30 12:02:30 +00:00
|
|
|
GOTO :start
|
|
|
|
:copyerror
|
|
|
|
::If at any point a copy error is encountered
|
|
|
|
TITLE Error!
|
|
|
|
ECHO.
|
|
|
|
ECHO An error in copying data has been encountered, returning an exit code of %ERRORLEVEL%
|
|
|
|
ECHO.
|
|
|
|
ECHO Make sure to close any files, such as `NadekoBot.db` before continuing or try running the installer as an Administrator
|
|
|
|
PAUSE >nul 2>&1
|
|
|
|
CD /D "%root%"
|
|
|
|
GOTO :EOF
|
2017-01-30 01:17:49 +00:00
|
|
|
:64BIT
|
|
|
|
ECHO.
|
|
|
|
ECHO Your System Architecture is 64bit...
|
|
|
|
GOTO end
|
|
|
|
:32BIT
|
|
|
|
ECHO.
|
|
|
|
ECHO Your System Architecture is 32bit...
|
|
|
|
timeout /t 5
|
|
|
|
ECHO.
|
2017-03-13 05:15:51 +00:00
|
|
|
ECHO Getting 32bit libsodium.dll and opus.dll...
|
|
|
|
IF EXIST "%root%NadekoBot\src\NadekoBot\_libs\32\libsodium.dll" (GOTO copysodium) ELSE (GOTO downloadsodium)
|
|
|
|
:copysodium
|
|
|
|
del "%root%NadekoBot\src\NadekoBot\libsodium.dll"
|
|
|
|
copy "%root%NadekoBot\src\NadekoBot\_libs\32\libsodium.dll" "%root%NadekoBot\src\NadekoBot\libsodium.dll"
|
|
|
|
ECHO libsodium.dll copied.
|
|
|
|
ECHO.
|
|
|
|
timeout /t 5
|
|
|
|
IF EXIST "%root%NadekoBot\src\NadekoBot\_libs\32\opus.dll" (GOTO copyopus) ELSE (GOTO downloadopus)
|
|
|
|
:downloadsodium
|
2017-01-30 01:17:49 +00:00
|
|
|
SET "FILENAME=%~dp0\NadekoBot\src\NadekoBot\libsodium.dll"
|
2017-03-04 23:05:55 +00:00
|
|
|
powershell -Command "Invoke-WebRequest https://github.com/Kwoth/NadekoBot/raw/dev/src/NadekoBot/_libs/32/libsodium.dll -OutFile '%FILENAME%'"
|
2017-01-30 01:17:49 +00:00
|
|
|
ECHO libsodium.dll downloaded.
|
|
|
|
ECHO.
|
|
|
|
timeout /t 5
|
2017-03-13 05:15:51 +00:00
|
|
|
IF EXIST "%root%NadekoBot\src\NadekoBot\_libs\32\opus.dll" (GOTO copyopus) ELSE (GOTO downloadopus)
|
|
|
|
:copyopus
|
|
|
|
del "%root%NadekoBot\src\NadekoBot\opus.dll"
|
|
|
|
copy "%root%NadekoBot\src\NadekoBot\_libs\32\opus.dll" "%root%NadekoBot\src\NadekoBot\opus.dll"
|
|
|
|
ECHO opus.dll copied.
|
|
|
|
GOTO end
|
|
|
|
:downloadopus
|
2017-01-30 01:17:49 +00:00
|
|
|
SET "FILENAME=%~dp0\NadekoBot\src\NadekoBot\opus.dll"
|
2017-03-04 23:05:55 +00:00
|
|
|
powershell -Command "Invoke-WebRequest https://github.com/Kwoth/NadekoBot/raw/dev/src/NadekoBot/_libs/32/opus.dll -OutFile '%FILENAME%'"
|
2017-01-31 21:38:31 +00:00
|
|
|
ECHO opus.dll downloaded.
|
2017-01-30 01:17:49 +00:00
|
|
|
GOTO end
|
2016-11-30 12:02:30 +00:00
|
|
|
:end
|
|
|
|
::Normal execution of end of script
|
2017-03-04 20:47:28 +00:00
|
|
|
TITLE NadekoBot Installation complete!
|
2016-11-30 12:02:30 +00:00
|
|
|
CD /D "%root%"
|
|
|
|
RMDIR /S /Q "%installtemp%" >nul 2>&1
|
|
|
|
ECHO.
|
2017-03-04 20:47:28 +00:00
|
|
|
ECHO Installation complete!
|
|
|
|
ECHO.
|
|
|
|
PAUSE
|
|
|
|
del Latest.bat
|