From: <ls...@us...> - 2008-08-25 20:26:26
|
Revision: 4504 http://jnode.svn.sourceforge.net/jnode/?rev=4504&view=rev Author: lsantha Date: 2008-08-25 20:19:53 +0000 (Mon, 25 Aug 2008) Log Message: ----------- Added support for running ${java.home}/jnode.ini one time in the shell after JNode startup. Modified Paths: -------------- trunk/all/conf/default-plugin-list.xml trunk/all/conf/full-plugin-list.xml trunk/all/conf/tests-plugin-list.xml trunk/shell/src/shell/org/jnode/shell/CommandShell.java Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2008-08-25 20:11:10 UTC (rev 4503) +++ trunk/all/conf/default-plugin-list.xml 2008-08-25 20:19:53 UTC (rev 4504) @@ -7,6 +7,7 @@ <plugin-list name="default"> <manifest> <attribute key="Main-Class" value="org.jnode.shell.CommandShell"/> + <attribute key="Main-Class-Arg" value="boot"/> </manifest> <plugin id="org.jnode.work"/> Modified: trunk/all/conf/full-plugin-list.xml =================================================================== --- trunk/all/conf/full-plugin-list.xml 2008-08-25 20:11:10 UTC (rev 4503) +++ trunk/all/conf/full-plugin-list.xml 2008-08-25 20:19:53 UTC (rev 4504) @@ -3,6 +3,7 @@ <plugin-list name="full"> <manifest> <attribute key="Main-Class" value="org.jnode.shell.CommandShell"/> + <attribute key="Main-Class-Arg" value="boot"/> </manifest> <include file="default-plugin-list.xml"/> Modified: trunk/all/conf/tests-plugin-list.xml =================================================================== --- trunk/all/conf/tests-plugin-list.xml 2008-08-25 20:11:10 UTC (rev 4503) +++ trunk/all/conf/tests-plugin-list.xml 2008-08-25 20:19:53 UTC (rev 4504) @@ -3,6 +3,7 @@ <plugin-list name="tests"> <manifest> <attribute key="Main-Class" value="org.jnode.shell.CommandShell"/> + <attribute key="Main-Class-Arg" value="boot"/> </manifest> <include file="full-plugin-list.xml"/> Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2008-08-25 20:11:10 UTC (rev 4503) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2008-08-25 20:19:53 UTC (rev 4504) @@ -78,7 +78,8 @@ public static final String HISTORY_PROPERTY_NAME = "jnode.history"; public static final String HISTORY_DEFAULT = "true"; - public static final String HOME_PROPERTY_NAME = "user.home"; + public static final String USER_HOME_PROPERTY_NAME = "user.home"; + public static final String JAVA_HOME_PROPERTY_NAME = "java.home"; public static final String DIRECTORY_PROPERTY_NAME = "user.dir"; public static final String INITIAL_INVOKER = "proclet"; @@ -161,6 +162,8 @@ private Thread ownThread; + private boolean bootShell; + public TextConsole getConsole() { return console; } @@ -168,6 +171,12 @@ public static void main(String[] args) throws NameNotFoundException, ShellException { CommandShell shell = new CommandShell(); + for (String arg : args) { + if ("boot".equals(arg)) { + shell.bootShell = true; + break; + } + } shell.run(); } @@ -274,18 +283,34 @@ } } - final String user_home = System.getProperty(HOME_PROPERTY_NAME, ""); + if (bootShell) { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { + final String java_home = System.getProperty(JAVA_HOME_PROPERTY_NAME, ""); + final File jnode_ini = new File(java_home + "/jnode.ini"); + try { + if (jnode_ini.exists()) { + runCommandFile(jnode_ini); + } + } catch (IOException ex) { + errPs.println("Error while reading " + jnode_ini + ": " + ex.getMessage()); + stackTrace(ex); + } + return null; + } + }); + } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { + final String user_home = System.getProperty(USER_HOME_PROPERTY_NAME, ""); final File shell_ini = new File(user_home + "/shell.ini"); try { if (shell_ini.exists()) { runCommandFile(shell_ini); } } catch (IOException ex) { - errPs.println("Error while reading " + shell_ini + ": " - + ex.getMessage()); + errPs.println("Error while reading " + shell_ini + ": " + ex.getMessage()); stackTrace(ex); } return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |