Page 1 of 1

Autostart application

Posted: Sun Apr 09, 2017 4:15 am
by chrisck87
Hi.
I've wrote a program in C for vocore2, it's working ok, now I need to make the vocore run this program after been powered on. I was reading a little and I found some posts that run scripts from the /etc/init.d/ directory but there is no any example of running an application, I mean like doing "./myapp" in the terminal.
How can I do it? :?

Re: Autostart application

Posted: Fri Apr 14, 2017 2:25 am
by Vonger
it is linux feature, you can put the command in /etc/rc.local

Re: Autostart application

Posted: Wed May 10, 2017 4:32 am
by chrisck87
Hi! I've already solved the problem.
1 create a file in /etc/init.d directory, for example: touch /etc/init.d/autostart
2 using vi editor write this code:
#!/bin/sh /etc/rc.common
SCRIPT_NAME="myapp"
SCRIPT_PATH="/path/to/your/app"
LOG_FILE="/tmp/myapp.log"
START=150
STOP=150
start() {
echo "Starting $SCRIPT_NAME"
$SPRIPT_PATH >> $LOG_FILE 2>&1 &
}
stop() {
echo "Stopping $SCRIPT_NAME"
pids=$(pgrep myapp)
kill -9 $pids
}

3 after that you must make the scripts executables writing:
chmod +x /path/to/your/app
chmod +x /etc/init.d/autostart

4 then test the script
/etc/init.d/autostart start

5 if everything is right, stop the test
/etc/init.d/autostart stop

6 Finally enable the autorun script
/etc/init.d/autostart enable

When you restart the vocore, the program "myapp" will be executed inmediately after booting