Reputation: 11
I got a problem with an Initscript on my Cubietruck working on Cubian (Debian Wheezy) I want to make an executable Jarfile start after booting.
Therefore i created the following ShellScript to start my jar (/usr/local/bin/startplt.sh):
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
JAVA=/usr/bin/java
JARFILE=/home/cubie/plt.jar
USER=cubie
/bin/su - $USER -c "$JAVA -jar $JARFILE &"
Running this script from console works.
Then I created another scriptfile working as a service to start/stop my Javaapplication. It should be written like the skeleton template but i did not get anything of that skeleton file. Here is my service (/etc/init.d/startjar)
#! /bin/sh
### BEGIN INIT INFO
# Provides: startjar
# Required-Start: $remote_fs $syslog $local_fs $network
# Required-Stop: $remote_fs $syslog $local_fs $network
# Default-Start: 5
# Default-Stop: 0 1 6
# Short-Description: Starts plt.jar
# Description: starts a the main jarfile
### END INIT INFO
NAME="startjar"
DESC="Starts /home/cubie/plt.jar"
test -x $DAEMON || exit 0
case "$1" in
start)
/usr/local/bin/startplt.sh
;;
stop)
pkill -f /home/cubie/plt.jar
pkill -f iceweasel
;;
*)
exit 1
;;
esac
exit 0
The Jar is starting Iceweasel to show some Data thats why its killed onStop. Starting and stopping of this script via console works with:
/etc/init.d/startjar start
/etc/init.d/startjar stop
As well as adding to services
insserv -d /etc/init.d/startjar
But after the boot nothing happens at all. Im not very familiar with runlevels and the required-stop/start variables actually not with shell scripting in general. I dont really see what am i doing wrong or what my scripts are missing :(
Can anyone tell me what i do wrong?
Upvotes: 0
Views: 1007
Reputation: 11
thank you very much for your help but i got another working solution by myself.
I created a desktop entry in /home/cubie/.config/autostart/
which starts my jar now after the xsession. im
Upvotes: 0
Reputation: 170
You have your service configured to start in runlevel 5, but Debian boots into runlevel 2 by default. This is probably why it doesn't start your service.
Modify Default-Start
to include 2, then run update-rc.d startjar defaults
or similar.
Incidentally, I think this question should be moved to serverfault.
Upvotes: 1