Page 1 of 1

Autorun application at startup in Linux

PostPosted: Sun Jan 27, 2019 11:47 am
by stubbornthings
What is the recommended way of running an application with IO on a target platform in Linux at startup? I have no problem starting the app with sbengine and then running the IO application from the command line separately, but I'm struggling to get both running at the same time.

I've tried using shells (config.sh) to start both apps but it will only start the first one that is called. I'm sure I'm missing something simple but I'm not sure what at this point.

Here is my current config.sh file.

Code: Select all
#! /bin/sh
export SB_PLUGINS=/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/plugins
export LD_LIBRARY_PATH=/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/lib:$LD_LIBRARY_PATH
echo $SB_PLUGINS
echo $LD_LIBRARY_PATH

sleep 1

cd /home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/bin
chmod +x sbengine

cd /home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/plugins
chmod +x *.so

cd

systemctl stop lxdm.service

echo -e '\033[9;0]' >> /dev/tty1

sleep 1

modprobe fusion_F0710A

sleep 1

# Display depth (16, 24, 32) 24/32 causes flickering on some displays
# fbset -depth 16

/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/bin/sbengine -vvvv -omtdev,device=/dev/input/touchscreen0 -ogesture,mode=multi -ogreio,channel=LCA.gapp /home/root/mnt/mmc/storyboard_export/LCA/LCA.gapp

cd /home/root/mnt/mmc/storyboard_export/LCA

chmod +x libmodbus
./libmodbus


Is there a better way to do this (Daemons, Systemd, etc.) or am I on the right track?

Thanks.

Re: Autorun application at startup in Linux

PostPosted: Mon Jan 28, 2019 10:20 am
by MikeMarchand
Hi Stubbornthings,

I'd say you are on the right track. I looks as if you're only missing an '&' at the end of the line launching Storyboard Engine. Otherwise, your script will block until sbengine is terminated, then it will finally execute ./libmodbus.

Cheers,
Mike

Re: Autorun application at startup in Linux

PostPosted: Mon Jan 28, 2019 11:16 am
by stubbornthings
Thanks Mike. Adding the & has solved my problem when using profile.d but I still need to login for it to work.

Do you know of a way I can get around having to login? Should I consider doing it another way, like using systemctl and a service?

Re: Autorun application at startup in Linux

PostPosted: Mon Jan 28, 2019 11:51 am
by MikeMarchand
You can use rc.d / init.d to execute your script in the startup sequence without being required to login first.

Re: Autorun application at startup in Linux

PostPosted: Tue Jan 29, 2019 4:54 pm
by stubbornthings
Hi Mike,

Thanks for the quick response but it's still not working for me.

I moved my script file to init.d and used update-rc.d -f script defaults to create the files that should open at startup, but it still only runs the first app (sbengine). It never runs the IO app. I'm kind of stuck so any other thoughts would be helpful. Thanks again.

Here is the updated script file.

Code: Select all
export SB_PLUGINS=/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/plugins
export LD_LIBRARY_PATH=/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/lib:$LD_LIBRARY_PATH
echo $SB_PLUGINS
echo $LD_LIBRARY_PATH

sleep 1

cd /home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/bin
chmod +x sbengine

cd /home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/plugins
chmod +x *.so

cd

systemctl stop lxdm.service

echo -e '\033[9;0]' >> /dev/tty1

sleep 1

modprobe fusion_F0710A

sleep 1

# Display depth (16, 24, 32) 24/32 causes flickering on some displays
# fbset -depth 16

cd /home/root/mnt/mmc/storyboard_export/LCA

chmod +x libmodbus

/home/root/mnt/mmc/storyboard_engines/linux-imx6dl/linux-imx6yocto-armle-fbdev-obj/bin/sbengine -vvvv -omtdev,device=/dev/input/touchscreen0 -ogesture,mode=multi -ogreio,channel=LCA.gapp /home/root/mnt/mmc/storyboard_export/LCA/LCA.gapp &
./libmodbus &