Compare commits

...

7 Commits

4 changed files with 99 additions and 83 deletions

View File

@ -72,7 +72,6 @@ build/I2P: I2P build
src/I2P/config:
mkdir -p src/I2P/config
rm -rf src/I2P/config/geoip src/I2P/config/webapps src/I2P/config/certificates
echo true | tee src/I2P/config/jpackaged
cp -v $(RES_DIR)/clients.config src/I2P/config/
cp -v $(RES_DIR)/wrapper.config src/I2P/config/
#grep -v 'router.updateURL' $(RES_DIR)/router.config > src/I2P/config/router.config

View File

@ -46,7 +46,7 @@ public class CopyConfigDir extends WindowsServiceUtil {
if (copyDirectory(file, new File(newPath)))
return false;
if (file.isFile())
if (!copyFile(file, new File(newPath), true))
if (0 == copyFile(file, new File(newPath), true))
return false;
}
return true;
@ -61,37 +61,49 @@ public class CopyConfigDir extends WindowsServiceUtil {
if (file.isDirectory())
if (!copyConfigDirectory(file, new File(newPath)))
return false;
if (file.isFile())
if (!copyFileNeverOverwrite(
file,
new File(newPath))) // new File(workDir, file.toString())))
if (file.isFile()) {
int cnr = copyFileNeverOverwrite(file, new File(newPath));
if (0 == cnr)
return false;
if (1 == cnr) {
logger.info("using jpackaged configs in a jpackaged install, creating jpackaged file");
File jpackagedConfigsInUse = new File(appImageHome(), "jpackaged");
if (!jpackagedConfigsInUse.exists()){
try{
jpackagedConfigsInUse.createNewFile();
}catch(IOException e){
logger.warning("Error creating jpackaged file, delete config files manually when uninstalling");
}
}
}
if (-1 == cnr) {
logger.info("not overwriting existing config file, not creating jpackaged file");
}
}
}
return true;
}
public static boolean copyFileNeverOverwrite(String basePath,
String workPath) {
public static int copyFileNeverOverwrite(String basePath, String workPath) {
File baseFile = new File(basePath);
File workFile = new File(workPath);
return copyFileNeverOverwrite(baseFile, workFile);
}
public static boolean copyFileNeverOverwrite(File basePath, File workPath) {
public static int copyFileNeverOverwrite(File basePath, File workPath) {
return copyFile(basePath, workPath, false);
}
public static boolean copyFile(File basePath, File workPath,
boolean overWrite) {
public static int copyFile(File basePath, File workPath, boolean overWrite) {
if (!basePath.exists()) {
logger.info(basePath.getAbsolutePath() + " doesn't exist, not copying");
return false;
return 0;
}
if (!overWrite && workPath.exists()) {
logger.info(workPath.getAbsolutePath() +
" already exists, not overwriting");
return true;
return -1;
}
File workDir = workPath.getParentFile();
@ -111,12 +123,12 @@ public class CopyConfigDir extends WindowsServiceUtil {
}
in.close();
out.close();
return true;
return 1;
} catch (Throwable e) {
logger.warning(e.toString());
logger.warning("failed to copy " + basePath.getAbsolutePath() + " to " +
workPath.getAbsolutePath());
return false;
return 0;
}
}

View File

@ -153,15 +153,26 @@ public class WinLauncher extends CopyConfigDir {
}
private static void fixServiceConfig() {
if (osName() != "windows")
return;
// If the user installed the Easy bundle before installing the
// regulalr bundle, then they have a config file which contains the
// IzPack installer, then they have a config file which contains the
// wrong update URL. Check for it, and change it back if necessary.
// closes #23
i2pRouter = new Router(routerConfig(), System.getProperties());
String routerconf = routerConfig();
if (routerconf != null) {
File routerconffile = new File(routerconf);
if (!routerconffile.exists()) {
return;
}
} else {
return;
}
if (isInstalled("i2p") || checkProgramFilesInstall()) {
i2pRouter = new Router(routerconf, System.getProperties());
String newsURL = i2pRouter.getConfigSetting("router.newsURL");
if (newsURL != null) {
if (newsURL.contains("win/beta")) {
if (newsURL.contains("http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/win/beta/news.su3")) {
logger.info(
"checked router.newsURL config, containes win/beta in a service install, invalid update type");
if (i2pRouter.saveConfig("router.newsURL", ServiceUpdaterString())) {
@ -172,7 +183,7 @@ public class WinLauncher extends CopyConfigDir {
}
String backupNewsURL = i2pRouter.getConfigSetting("router.backupNewsURL");
if (backupNewsURL != null) {
if (backupNewsURL.contains("win/beta")) {
if (backupNewsURL.contains("http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/win/beta/news.su3")) {
logger.info(
"checked router.backupNewsURL config, containes win/beta in a service install, invalid update type");
if (i2pRouter.saveConfig("router.backupNewsURL",
@ -184,9 +195,9 @@ public class WinLauncher extends CopyConfigDir {
}
String updateURL = i2pRouter.getConfigSetting("router.updateURL");
if (updateURL != null) {
if (updateURL.contains("i2pwinupdate.su3")) {
if (updateURL.contains("http://ekm3fu6fr5pxudhwjmdiea5dovc3jdi66hjgop4c7z7dfaw7spca.b32.i2p/i2pwinupdate.su3")) {
logger.info(
"checked router.updateURL config, containes win/beta in a service install, invalid update type");
"checked router.updateURL config, containes easy-intall update in a service install, invalid update type");
if (i2pRouter.saveConfig("router.updateURL",
ServiceStaticUpdaterString())) {
logger.info("updated routerconsole.browser config " +

View File

@ -4,7 +4,7 @@ UniCode true
!define APPNAME "I2PBrowser-Launcher"
!define COMPANYNAME "I2P"
!define DESCRIPTION "This is a tool which contains an I2P router, a bundled JVM, and a tool for automatically configuring a browser to use with I2P."
!define I2P_MESSAGE "Could not find I2P. Installing portable Jpackaged I2P."
!define I2P_MESSAGE "Please choose a directory."
!define LAUNCH_TEXT "Start I2P?"
!define LICENSE_TITLE "Many Licenses"
!define CONSOLE_URL "http://127.0.0.1:7657/home"
@ -13,11 +13,11 @@ UniCode true
!include i2pbrowser-jpackage.nsi
!include FindProcess.nsh
var I2PINSTEXE
var INSTDIR
SetOverwrite on
!define I2PINSTEXE
!define INSTDIR
!define I2PINSTEXE_USERMODE "$LOCALAPPDATA\i2p"
!define RAM_NEEDED_FOR_64BIT 0x80000000
@ -122,18 +122,18 @@ PageEx license
PageExEnd
PageEx directory
dirtext "${I2P_MESSAGE}"
dirvar $I2PINSTEXE
dirvar $INSTDIR
PageCallbacks routerDetect
PageExEnd
Page instfiles
Function .onInit
StrCpy $I2PINSTEXE "${I2PINSTEXE_USERMODE}"
StrCpy $INSTDIR "${I2PINSTEXE_USERMODE}"
UserInfo::GetAccountType
pop $0
${If} $0 != "admin"
StrCpy $INSTDIR "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}"
StrCpy $I2PINSTEXE "${I2PINSTEXE_USERMODE}"
StrCpy $INSTDIR "${I2PINSTEXE_USERMODE}"
StrCpy $INSTDIR "${I2PINSTEXE_USERMODE}"
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY
#Call ShouldInstall64Bit
@ -141,34 +141,22 @@ Function .onInit
FunctionEnd
Function routerDetect
createDirectory $I2PINSTEXE
SetOutPath $I2PINSTEXE\app
createDirectory $INSTDIR
SetOutPath $INSTDIR\app
File /a /r "I2P\app\"
SetOutPath $I2PINSTEXE\runtime
SetOutPath $INSTDIR\runtime
File /a /r "I2P\runtime\"
SetOutPath $I2PINSTEXE
SetOutPath $INSTDIR\config
File /a /r "I2P\config\"
SetOutPath $INSTDIR
File /a /r "I2P\I2P.exe"
# The NSIS Installer uses an ico icon, the jpackage-only ones use png
File /a /r "I2P\ui2pbrowser_icon.ico"
File "I2P\config\jpackaged"
createDirectory "$I2PINSTEXE\"
SetOutPath "$I2PINSTEXE\"
IfFileExists $I2PINSTEXE\router.config +2 0
File /a /r "I2P/config/router.config"
IfFileExists $I2PINSTEXE\clients.config +2 0
File /a /r "I2P/config/clients.config"
IfFileExists $I2PINSTEXE\wrapper.config +2 0
File /a /r "I2P/config/wrapper.config"
IfFileExists $I2PINSTEXE\hosts.txt +2 0
File /a /r "I2P/config/hosts.txt"
IfFileExists $I2PINSTEXE\eepsite +2 0
File /a /r "I2P/config/eepsite"
IfFileExists $I2PINSTEXE\webapps +2 0
File /a /r "I2P/config/webapps"
createDirectory "$INSTDIR\"
SetOutPath "$INSTDIR\"
File /a /r "I2P/config/certificates"
File /a /r "I2P/config/geoip"
File /a /r "I2P/config/i2ptunnel.config"
FunctionEnd
Function installerFunction
@ -178,28 +166,19 @@ Function installerFunction
Sleep 500
${LoopWhile} $0 <> 0
${EndIf}
# delete the jpackaged file for safety. Remove this IMMEDIATELY after the next release.
# early-adopters and daily-build users may have to manually delete config files if they
# uninstall.
# RELATED: line 246
Delete "$INSTDIR\jpackaged"
# set the installation directory as the destination for the following actions
createDirectory $INSTDIR
SetOutPath $INSTDIR
File ui2pbrowser_icon.ico
# Update jpackaged I2P router, if it exists
${If} ${FileExists} "$I2PINSTEXE\jpackaged"
createDirectory $I2PINSTEXE
SetOutPath $I2PINSTEXE
${If} ${Silent}
ReadEnvStr $0 OLD_I2P_VERSION
${If} $0 < ${I2P_VERSION}
call routerDetect
${EndIf}
${Else}
call routerDetect
${EndIf}
${EndIf}
# Update jpackaged I2P router
call routerDetect
# Install the launcher scripts
createDirectory "$INSTDIR"
@ -211,13 +190,13 @@ Function installerFunction
SetOutPath "$INSTDIR\licenses"
File /a /r "licenses/*"
SetOutPath "$I2PINSTEXE"
SetOutPath "$INSTDIR"
createDirectory "$SMPROGRAMS\${APPNAME}"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Browse I2P.lnk" "$I2PINSTEXE\I2P.exe" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Browse I2P - Temporary Identity.lnk" "$I2PINSTEXE\I2P.exe -private" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Browse I2P.lnk" "$INSTDIR\I2P.exe" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Browse I2P - Temporary Identity.lnk" "$INSTDIR\I2P.exe -private" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$DESKTOP\Browse I2P.lnk" "$I2PINSTEXE\I2P.exe" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$DESKTOP\Browse I2P - Temporary Identity.lnk" "$I2PINSTEXE\I2P.exe -private" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$DESKTOP\Browse I2P.lnk" "$INSTDIR\I2P.exe" "" "$INSTDIR\ui2pbrowser_icon.ico"
CreateShortCut "$DESKTOP\Browse I2P - Temporary Identity.lnk" "$INSTDIR\I2P.exe -private" "" "$INSTDIR\ui2pbrowser_icon.ico"
SetOutPath "$INSTDIR"
SetShellVarContext current
@ -225,8 +204,8 @@ Function installerFunction
IfFileExists "$LOCALAPPDATA\I2P\eepsite\docroot" +2 0
File /a /r "I2P\eepsite"
createDirectory "$I2PINSTEXE"
SetOutPath "$I2PINSTEXE"
createDirectory "$INSTDIR"
SetOutPath "$INSTDIR"
SetOutPath "$INSTDIR"
# create the uninstaller
@ -245,12 +224,13 @@ SectionEnd
# uninstaller section start
Section "uninstall"
# Uninstall the launcher scripts
Delete $INSTDIR\*
rmDir /r "$INSTDIR\"
${If} ${FileExists} "$I2PINSTEXE\jpackaged"
Delete $I2PINSTEXE\*
rmDir /r "$I2PINSTEXE"
${EndIf}
rmDir /r "$INSTDIR\app"
rmDir /r "$INSTDIR\config"
rmDir /r "$INSTDIR\runtime"
Delete "$INSTDIR\ui2pbrowser_icon.ico"
Delete "$INSTDIR\windowsUItoopie2.png"
Delete "$INSTDIR\I2P.exe"
# Remove shortcuts and folders
Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
@ -262,11 +242,25 @@ Section "uninstall"
Delete "$DESKTOP\${APPNAME}.lnk"
Delete "$DESKTOP\Private Browsing-${APPNAME}.lnk"
rmDir /r "$SMPROGRAMS\${APPNAME}"
rmDir /r "$INSTDIR\firefox.profile.i2p\extensions"
rmDir /r "$INSTDIR\firefox.profile.i2p"
rmDir /r "$LOCALAPPDATA\${APPNAME}"
rmDir /r "$INSTDIR"
#### SUPER SUPER EXTRA IMPORTANT!
### RELATED: line 169
## IF YOU DO THIS WRONG YOU WILL BREAK CONFIGS:
## The purpose of the `jpackaged` file has changed, as has the point
## where it is created.
# 1. The jpackaged file is now created only **after** the jpackage itself
# has migrated default configs into the $INSTDIR. IF THEY ALREADY EXIST,
# it WILL NOT BE CREATED, even if there is a jpackage present. This is
# intentional behavior.
# 2. The jpackaged file now indicates that the configurations were created
# by running the jpackage, and not by an un-bundled router. If it is not
# present, then we have already deleted everything we are responsible for
# and don't need to do the section below.
${If} ${FileExists} "$INSTDIR\jpackaged"
Delete $INSTDIR\*
rmDir /r "$INSTDIR"
${EndIf}
# delete the uninstaller
Delete "$INSTDIR\uninstall-i2pbrowser.exe"
@ -280,8 +274,8 @@ SectionEnd
!insertmacro MUI_PAGE_FINISH
Function LaunchLink
SetOutPath "$I2PINSTEXE"
StrCpy $OUTDIR $I2PINSTEXE
SetOutPath "$INSTDIR"
StrCpy $OUTDIR $INSTDIR
${If} ${Silent}
ReadEnvStr $0 RESTART_I2P
${If} $0 != ""