|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.claudio.pen.Init1
public class Init1
Init replacement in Java
As I intend to run just Paper on my tablet computer, I wanted to have a very
reduced Linux environment. Thus I thought to replace standard init, and
execute Java right from Linux. To do so, the boot loader needs to execute the
kernel with an init=/init.sh
argument. This wil execute the
shell script /init.sh that should contain:
#!/bin/sh export DISPLAY=:0 while ! java -jar init.jar; do echo "Java crashed"; done kill -TERM -1 sleep 1 kill -KILL -1 sleep 1 umount -a sync halt -n -f -p
The DISPLAY variable is only set here, because I do not know how to set it from within of this class. It can be left out in environments, where an X server is never started. The init.jar is executed which contains all classes and has this class defined as main class. If it returns with an error exit code it is restarted, otherwise the computer is shut down.
If reboot from here (through native library): Linux has a (2)reboot system call which accepts an argument: RB_POWER_OFF will halt and RB_AUTOBOOT will reboot. This call might return before the kernel shut down, thus after this call a wait needs to be placed and init must not be exited, because termination of process 1 would make the kernel panic
Copyright (C) 2006 Claudio Nieder <private@claudio.ch>, CH-8610 Uster
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Constructor Summary | |
---|---|
Init1()
|
Method Summary | |
---|---|
static void |
main(java.lang.String[] args)
Print license. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Init1()
Method Detail |
---|
public static void main(java.lang.String[] args)
args
- ignored
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |