Allow specification of appbase via system property.
This allows one to bootstrap a Getdown install with no files at all. You don't get a very sexy UI during the first install, but you can make something non-horrible with a background color and a small window.
This commit is contained in:
@@ -261,7 +261,7 @@ public class Application
|
||||
try {
|
||||
return createResource(CONFIG_FILE, false);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid appbase '" + _vappbase + "'.");
|
||||
throw new RuntimeException("Invalid appbase '" + _vappbase + "'.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,10 +472,10 @@ public class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the application to parse its <code>getdown.txt</code> configuration and prepare
|
||||
* itself for operation. The application base URL will be parsed first so that if there are
|
||||
* errors discovered later, the caller can use the application base to download a new
|
||||
* <code>config.txt</code> file and try again.
|
||||
* Instructs the application to parse its {@code getdown.txt} configuration and prepare itself
|
||||
* for operation. The application base URL will be parsed first so that if there are errors
|
||||
* discovered later, the caller can use the application base to download a new {@code
|
||||
* getdown.txt} file and try again.
|
||||
*
|
||||
* @return a configured UpdateInterface instance that will be used to configure the update UI.
|
||||
*
|
||||
@@ -485,26 +485,36 @@ public class Application
|
||||
public UpdateInterface init (boolean checkPlatform)
|
||||
throws IOException
|
||||
{
|
||||
// parse our configuration file
|
||||
Map<String,Object> cdata = null;
|
||||
File config = _config;
|
||||
try {
|
||||
// if we have a configuration file, read the data from it
|
||||
if (config.exists()) {
|
||||
cdata = ConfigUtil.parseConfig(_config, checkPlatform);
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
// thanks to funny windows bullshit, we have to do this backup file fiddling in case we
|
||||
// got screwed while updating our very critical getdown config file
|
||||
File cbackup = getLocalPath(CONFIG_FILE + "_old");
|
||||
if (cbackup.exists()) {
|
||||
cdata = ConfigUtil.parseConfig(cbackup, checkPlatform);
|
||||
} else {
|
||||
throw fnfe;
|
||||
}
|
||||
// otherwise, try reading data from our backup config file; thanks to funny windows
|
||||
// bullshit, we have to do this backup file fiddling in case we got screwed while
|
||||
// updating getdown.txt during normal operation
|
||||
else if ((config = getLocalPath(CONFIG_FILE + "_old")).exists()) {
|
||||
cdata = ConfigUtil.parseConfig(config, checkPlatform);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warning("Failure reading config file", "file", config, e);
|
||||
}
|
||||
// if we failed to read our config file, check for an appbase specified via a system
|
||||
// property; we can use that to bootstrap ourselves back into operation
|
||||
if (cdata == null) {
|
||||
log.info("Found no getdown.txt file. Falling back to appbase system prop",
|
||||
"appbase", SysProps.appBase());
|
||||
cdata = new HashMap<String,Object>();
|
||||
cdata.put("appbase", SysProps.appBase());
|
||||
}
|
||||
|
||||
// first determine our application base, this way if anything goes wrong later in the
|
||||
// process, our caller can use the appbase to download a new configuration file
|
||||
_appbase = (String)cdata.get("appbase");
|
||||
if (_appbase == null) {
|
||||
throw new IOException("m.missing_appbase");
|
||||
throw new RuntimeException("m.missing_appbase");
|
||||
}
|
||||
// make sure there's a trailing slash
|
||||
if (!_appbase.endsWith("/")) {
|
||||
@@ -524,11 +534,7 @@ public class Application
|
||||
|
||||
// if we are a versioned deployment, create a versioned appbase
|
||||
try {
|
||||
if (_version < 0) {
|
||||
_vappbase = new URL(_appbase);
|
||||
} else {
|
||||
_vappbase = createVAppBase(_version);
|
||||
}
|
||||
_vappbase = (_version < 0) ? new URL(_appbase) : createVAppBase(_version);
|
||||
} catch (MalformedURLException mue) {
|
||||
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
||||
throw (IOException) new IOException(err).initCause(mue);
|
||||
|
||||
@@ -23,6 +23,12 @@ public class SysProps
|
||||
return System.getProperty("appid");
|
||||
}
|
||||
|
||||
/** Configures the appbase (in lieu of providing a skeleton getdown.txt, and as a last resort
|
||||
* fallback). Usage: {@code -Dappbase=someurl}. */
|
||||
public static String appBase () {
|
||||
return System.getProperty("appbase");
|
||||
}
|
||||
|
||||
/** If true, disables redirection of logging into {@code launcher.log}.
|
||||
* Usage: {@code -Dno_log_redir}. */
|
||||
public static boolean noLogRedir () {
|
||||
|
||||
Reference in New Issue
Block a user