Axis Customer Forum

It is currently Tue Dec 18, 2018 11:10 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Start script at boot
PostPosted: Fri May 11, 2018 12:57 pm 

Joined: Tue Feb 21, 2017 5:58 pm
Posts: 19
Dear Support,

I wrote a little script to the Axis C8033 Audio Bridge. I'd like my script run when it boots.

I've created a /etc/task.list file
containing this line:
once % /etc/scripts/myscript;
but it never gets executed.

I've also tried to make an init script, with update-rc.d, but there is no update-rc.d command available on this product, moreover there is no cron either.

Could you tell me a way to run my script on boot?

Thanks,


Top
 Profile  
 
 Post subject: Re: Start script at boot
PostPosted: Mon May 14, 2018 1:30 am 

Joined: Fri Nov 14, 2014 1:38 am
Posts: 639
Not very sure which firmware your audio bridge is running. Try to find the last script that it execute at bootup and pend your script in it.

Anyway I do not have an audio bridge to test. So this will be as far as I can help you. Good Luck


Top
 Profile  
 
 Post subject: Re: Start script at boot
PostPosted: Mon May 14, 2018 7:29 am 

Joined: Tue Feb 21, 2017 5:58 pm
Posts: 19
Hi,

The firmware is the latest. I tried to append my script to an existing shell script, but it's on readonly filesystem. Altogether I tried 4 different aproach to get it done:

1. symink to all runlevels:
I placed my script into /etc/init.d, the script contains this:
#!/bin/sh
logger 'test'
touch /var/spool/storage/SD_DISK/test.txt


and I made symlinks in each runlevel like this:
Code:
ln -s /etc/init.d/myscript.sh /etc/rc0.d/S01myscript
all the way through:
ln -s /etc/init.d/myscript.sh /etc/rc6.d/S01myscript

Nothing happens :-( I made sure that 777 has been set on my script.

2. Created a task.list file under /etc folder
Do you think that /etc/task.list file makes a difference? - None of them will have an effect on boot.
once % /etc/init.d/myscript.sh;
or
once % sh /etc/init.d/myscript.sh;

3. created an rc.local file, with 755, rebooting
- doesn't work...

4. I've tried to trigger an rc.local file with systemd, and I managed to sqeez out some information, i suppose my rc-local.service file is not well formatted:

/etc/systemd/system/rc-local.service file contains this:
Code:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target


/etc/rc.local file contains this:
Code:
#!/bin/sh -e

sh /etc/init.d/myscript &


systemctl enable rc-local.service OK
systemctl start rc-local.service ERROR: failed ExecStart/etc/rc.local start (code=exited, status=2)


If you have a proper rc-local.service file, please share it.

Thanks


Top
 Profile  
 
 Post subject: Re: Start script at boot
PostPosted: Tue May 15, 2018 1:53 pm 

Joined: Tue Feb 21, 2017 5:58 pm
Posts: 19
Today I continued testing with systemd. In order to do that I created a file for testing purpuses:
/etc/init.d/start.sh
Code:
#!/bin/sh
echo "Frog START: $(date), PID: $$" >> /var/log/test.log


And a service file in /etc/systemd/system:
frog.service
Code:
[Unit]
Description=Test Application
After=network.target

[Service]
Type=oneshot
User=root
ExecStart=/etc/init.d/start.sh

[Install]
WantedBy=default.target

Then :
Code:
systemctl daemon-reload
systemctl enable frog.service
systemctl start frog.service
systemctl daemon-reload

Deleted the newly created file:
Code:
rm /var/log/frogtest.log


Interestingly after powering off and on the device, the /var/log/frogtest.log file contains 2 lines with the exact date.

Code:
Frog START: Wed May 16 11:26:39 GMT 2018, PID: 574
Frog START: Wed May 16 11:26:39 GMT 2018, PID: 575


It looks like as if the the start.sh and stop.sh script have run 2 times during the boot, with exact timings, but the PIDs are different.

Do you guys have any idea?


Top
 Profile  
 
 Post subject: Re: Start script at boot
PostPosted: Mon May 21, 2018 2:51 am 

Joined: Fri Nov 14, 2014 1:38 am
Posts: 639
In your start.sh, you have to check if it is already running.

If it is, do not execute it the second time.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group