From 2774c5d81c5c076f256e9ef13c51ec42bfe58ab1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 29 Nov 2016 14:36:56 +0100 Subject: [PATCH 1/2] updated discord.net --- discord.net | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.net b/discord.net index 95a4f7a7..48b66d55 160000 --- a/discord.net +++ b/discord.net @@ -1 +1 @@ -Subproject commit 95a4f7a73e2b66bef3a841ac6b415f7269839f42 +Subproject commit 48b66d55f3f26f60fc001123ff6d7afeade3a51d From 5d3b99c445c6c40fcfc3ba8f39f77e20849690e4 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 29 Nov 2016 19:36:53 +0100 Subject: [PATCH 2/2] added install scripts --- scripts/NadekoAutoRun.bat | 6 ++ scripts/NadekoInstaller.bat | 110 ++++++++++++++++++++++++++++++ scripts/NadekoInstallerLatest.bat | 110 ++++++++++++++++++++++++++++++ scripts/NadekoRun.bat | 9 +++ 4 files changed, 235 insertions(+) create mode 100644 scripts/NadekoAutoRun.bat create mode 100644 scripts/NadekoInstaller.bat create mode 100644 scripts/NadekoInstallerLatest.bat create mode 100644 scripts/NadekoRun.bat diff --git a/scripts/NadekoAutoRun.bat b/scripts/NadekoAutoRun.bat new file mode 100644 index 00000000..af1b87d5 --- /dev/null +++ b/scripts/NadekoAutoRun.bat @@ -0,0 +1,6 @@ +@ECHO off +@TITLE NadekoBot +:auto +CD /D %~dp0NadekoBot\src\NadekoBot +dotnet run --configuration Release +goto auto diff --git a/scripts/NadekoInstaller.bat b/scripts/NadekoInstaller.bat new file mode 100644 index 00000000..f52d1e07 --- /dev/null +++ b/scripts/NadekoInstaller.bat @@ -0,0 +1,110 @@ +@ECHO off +TITLE Downloading NadekoBot, please wait +::Setting convenient to read variables which don't delete the windows temp folder +SET root=%~dp0 +CD /D %root% +SET rootdir=%cd% +SET build1=%root%NadekoInstall_Temp\NadekoBot\discord.net\src\Discord.Net\ +SET build2=%root%NadekoInstall_Temp\NadekoBot\discord.net\src\Discord.Net.Commands\ +SET build3=%root%NadekoInstall_Temp\NadekoBot\src\NadekoBot\ +SET installtemp=%root%NadekoInstall_Temp\ +::Deleting traces of last setup for the sake of clean folders, if by some miracle it still exists +IF EXIST %installtemp% ( RMDIR %installtemp% /S /Q >nul 2>&1) +::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 +MKDIR NadekoInstall_Temp +CD /D %installtemp% +::Downloads the latest version of Nadeko +ECHO Downloading Nadeko... +ECHO. +git clone -b 1.0 --recursive --depth 1 --progress https://github.com/Kwoth/NadekoBot.git >nul +IF %ERRORLEVEL% EQU 128 (GOTO :giterror) +TITLE Installing NadekoBot, please wait +ECHO. +ECHO Installing... +::Building Nadeko +CD /D %build1% +dotnet restore >nul 2>&1 +CD /D %build2% +dotnet restore >nul 2>&1 +CD /D %build3% +dotnet restore >nul 2>&1 +dotnet build --configuration Release >nul 2>&1 +::Attempts to backup old files if they currently exist in the same folder as the batch file +IF EXIST "%root%NadekoBot\" (GOTO :backupinstall) +:freshinstall + ::Moves the NadekoBot folder to keep things tidy + ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + GOTO :end +:backupinstall + TITLE Backing up old files + ECHO. + ECHO Make sure to close any files such as NadekoBot.db before PRESSing ANY KEY TO CONTINUE to prevent data loss + PAUSE >nul 2>&1 + ::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. + ECHO Old files backed up to NadekoBot_Old + ::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. + ECHO credentials.json copied to new folder + ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\bin" "%installtemp%NadekoBot\src\NadekoBot\bin" /E >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + ECHO. + ECHO Old bin folder copied to new folder + ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\data" "%installtemp%NadekoBot\src\NadekoBot\data" /E >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + ECHO. + ECHO Old data folder copied to new folder + ::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) + GOTO :end +: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 + RMDIR %installtemp% /S /Q >nul 2>&1 + 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 +:end + ::Normal execution of end of script + TITLE Installation complete! + CD /D "%root%" + RMDIR /S /Q "%installtemp%" >nul 2>&1 + ECHO. + ECHO Installation complete, press any key to close this window! + PAUSE >nul 2>&1 + del NadekoStable.bat diff --git a/scripts/NadekoInstallerLatest.bat b/scripts/NadekoInstallerLatest.bat new file mode 100644 index 00000000..8cb53ee4 --- /dev/null +++ b/scripts/NadekoInstallerLatest.bat @@ -0,0 +1,110 @@ +@ECHO off +TITLE Downloading NadekoBot, please wait +::Setting convenient to read variables which don't delete the windows temp folder +SET root=%~dp0 +CD /D %root% +SET rootdir=%cd% +SET build1=%root%NadekoInstall_Temp\NadekoBot\discord.net\src\Discord.Net\ +SET build2=%root%NadekoInstall_Temp\NadekoBot\discord.net\src\Discord.Net.Commands\ +SET build3=%root%NadekoInstall_Temp\NadekoBot\src\NadekoBot\ +SET installtemp=%root%NadekoInstall_Temp\ +::Deleting traces of last setup for the sake of clean folders, if by some miracle it still exists +IF EXIST %installtemp% ( RMDIR %installtemp% /S /Q >nul 2>&1) +::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 +MKDIR NadekoInstall_Temp +CD /D %installtemp% +::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) +TITLE Installing NadekoBot, please wait +ECHO. +ECHO Installing... +::Building Nadeko +CD /D %build1% +dotnet restore >nul 2>&1 +CD /D %build2% +dotnet restore >nul 2>&1 +CD /D %build3% +dotnet restore >nul 2>&1 +dotnet build --configuration Release >nul 2>&1 +::Attempts to backup old files if they currently exist in the same folder as the batch file +IF EXIST "%root%NadekoBot\" (GOTO :backupinstall) +:freshinstall + ::Moves the NadekoBot folder to keep things tidy + ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + GOTO :end +:backupinstall + TITLE Backing up old files + ECHO. + ECHO Make sure to close any files such as NadekoBot.db before PRESSing ANY KEY TO CONTINUE to prevent data loss + PAUSE >nul 2>&1 + ::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. + ECHO Old files backed up to NadekoBot_Old + ::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. + ECHO credentials.json copied to new folder + ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\bin" "%installtemp%NadekoBot\src\NadekoBot\bin" /E >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + ECHO. + ECHO Old bin folder copied to new folder + ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\data" "%installtemp%NadekoBot\src\NadekoBot\data" /E >nul 2>&1 + IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror) + ECHO. + ECHO Old data folder copied to new folder + ::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) + GOTO :end +: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 + RMDIR %installtemp% /S /Q >nul 2>&1 + 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 +:end + ::Normal execution of end of script + TITLE Installation complete! + CD /D "%root%" + RMDIR /S /Q "%installtemp%" >nul 2>&1 + ECHO. + ECHO Installation complete, press any key to close this window! + PAUSE >nul 2>&1 + del NadekoLatest.bat diff --git a/scripts/NadekoRun.bat b/scripts/NadekoRun.bat new file mode 100644 index 00000000..207fb278 --- /dev/null +++ b/scripts/NadekoRun.bat @@ -0,0 +1,9 @@ +@ECHO off +@TITLE NadekoBot +CD /D %~dp0NadekoBot\src\NadekoBot +dotnet run --configuration Release +ECHO NadekoBot has been succesfully stopped, press any key to close this window. +TITLE NadekoBot - Stopped +CD /D %~dp0 +PAUSE >nul 2>&1 +del NadekoRunNormal.bat