From 57ad0d1eeae7c5ade74c0888e3841a19b4fff737 Mon Sep 17 00:00:00 2001 From: anonimal Date: Tue, 21 Feb 2017 20:14:10 +0000 Subject: [PATCH] Kovri: implement preliminary Windows install script - Unfinished, very buggy, see TODO's - At a minimum, installs needed files References: - monero-project/meta#50 - monero-project/meta#35 - monero-project/kovri#362 --- kovri/install.bat | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 kovri/install.bat diff --git a/kovri/install.bat b/kovri/install.bat new file mode 100755 index 0000000..7c1bccc --- /dev/null +++ b/kovri/install.bat @@ -0,0 +1,95 @@ +@ECHO OFF + +REM Copyright (c) 2017, The Kovri I2P Router Project +REM +REM All rights reserved. +REM +REM Redistribution and use in source and binary forms, with or without modification, are +REM permitted provided that the following conditions are met: +REM +REM 1. Redistributions of source code must retain the above copyright notice, this list of +REM conditions and the following disclaimer. +REM +REM 2. Redistributions in binary form must reproduce the above copyright notice, this list +REM of conditions and the following disclaimer in the documentation and/or other +REM materials provided with the distribution. +REM +REM 3. Neither the name of the copyright holder nor the names of its contributors may be +REM used to endorse or promote products derived from this software without specific +REM prior written permission. +REM +REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +REM EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +REM MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +REM THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +REM SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +REM PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +REM INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +REM STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +REM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +SET _banner=The Kovri I2P Router Project Installer +SET _data=%APPDATA%\Kovri + +REM Backup existing installation +SET _config=%_data%\config +SET _kovri_conf=%_config%\kovri.conf +SET _tunnels_conf=%_config%\tunnels.conf + +REM TODO(anonimal): implement +REM IF EXIST "%_config%%" ( +REM ECHO Begin configuration backup... +REM IF EXIST "%_kovri_conf%" ( +REM MOVE /Y "%_kovri_conf%" "%_kovri_conf%".bak +REM ) +REM IF EXIST "%_tunnels_conf%" ( +REM MOVE /Y "%_tunnels_conf%" "%_tunnels_conf%".bak +REM ) +REM CALL :catch could not backup configuration +REM ) + +REM Remove existing install +SET _core=%_data%\core +SET _client=%_data%\client +SET _installed[0]="%_core%" +SET _installed[1]="%_client%\address_book\addresses" +SET _installed[2]="%_client%\address_book\addresses.csv" +SET _installed[3]="%_client%\certificates" + +REM TODO(anonimal): implement +REM FOR /F "tokens=2 delims==" %%s IN ('set _installed[') DO IF EXIST %%s (ECHO Removing %%s && DEL /S /Q %%s) +CALL :catch could not remove existing install + +REM Create new install +REM TODO(anonimal): Install to Program Files? +SET _path=%USERPROFILE%\Desktop +SET _binary=kovri.exe + +IF NOT EXIST "%_data%%" ( + ECHO Creating "%_data%" + MKDIR "%_data%" + CALL :catch could not create "%_data%" +) + +IF NOT EXIST "%_path%%" ( + ECHO Creating "%_path%" + MKDIR "%_path%" + CALL :catch could not create "%_path%" +) + +SET _resources[0]=client +SET _resources[1]=config +SET _resources[2]=%_binary% + +REM TODO(anonimal): prefer to copy +FOR /F "tokens=2 delims==" %%s IN ('set _resources[') DO IF %%s == %_binary% (MOVE /Y %%s "%_path%") else (MOVE /Y %%s "%_data%") +CALL :catch could not install resources + +ECHO Installation success! + +:catch +IF %ERRORLEVEL% NEQ 0 ( + ECHO " [ERROR] Failed to install: '%*'" + EXIT /B 1 +) +GOTO :EOF