Autostart application

chrisck87
 
Posts: 3
Joined: Fri Mar 17, 2017 10:33 pm

Autostart application

Sun Apr 09, 2017 4:15 am

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? :?

Vonger
 
Posts: 896
Joined: Sun Oct 19, 2014 6:00 am

Re: Autostart application

Fri Apr 14, 2017 2:25 am

it is linux feature, you can put the command in /etc/rc.local

chrisck87
 
Posts: 3
Joined: Fri Mar 17, 2017 10:33 pm

Re: Autostart application

Wed May 10, 2017 4:32 am

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

Return to VoCore2/Lite/Ultimate

Who is online

Users browsing this forum: No registered users and 39 guests