WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: PCP / ASH script won't run from bootlocal  (Read 3181 times)

Offline jeff_69_fr

  • Newbie
  • *
  • Posts: 3
PCP / ASH script won't run from bootlocal
« on: October 20, 2017, 10:02:12 AM »
Hello, I'm on issue to obtain the autostart of an ASH script on PiCorePlayer.

this script is working well from the command line,
but no way to obtain the script starting normally from bootlocal
- with / without using sudo
- using / not using the paths

below my bootlocal.sh file  and the script
I don' find any related post, sorry if the point is obviousl  I'm a newbie on such topics 

thanks in advance for your advises

my current bootlocal.sh

Code: [Select]
[#!/bin/sh
# put other system startup commands here

/opt/eth0.sh
GREEN="$(echo -e '\033[1;32m')"

echo
echo "${GREEN}Running bootlocal.sh..."
#pCPstart------
/home/tc/www/cgi-bin/do_rebootstuff.sh 2>&1 | tee -a /var/log/pcp_boot.log
#pCPstop------
/usr/local/etc/init.d/lcdproc-server start
/usr/local/etc/init.d/pikeyd start
/usr/local/etc/init.d/slimmer start
python /usr/local/etc/init.d/shutdown-button.py
/bin/ash /usr/local/etc/init.d/squeezelite_led.sh &

and the script  /  to activate 2 leds depending of squeezelite running or not

Code: [Select]
#!/bin/ash

# wiringPy mode
LED1=3
LED2=5

# set-up
setup()
{
gpio mode $LED1 out
gpio write $LED1 0
gpio mode $LED2 out
gpio write $LED2 0
}

#loop
loop()
{
squeezelite=$(ps -ef | grep MainPlayer | grep -v "grep" | wc -l)
if [ $squeezelite -eq 0  ]; # If squeezelite isn't playing
then
gpio write $LED1 0
gpio write $LED2 1
else
gpio write $LED1 1
gpio write $LED2 0
fi
sleep 1
}

# main
setup
while true;
do
        loop
done


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: PCP / ASH script won't run from bootlocal
« Reply #1 on: October 20, 2017, 10:17:05 AM »
Hi jeff_69_fr
Code: [Select]
/bin/ash /usr/local/etc/init.d/squeezelite_led.sh & That doesn't look right. It should look like:
Code: [Select]
/usr/local/etc/init.d/squeezelite_led.sh &

Offline jeff_69_fr

  • Newbie
  • *
  • Posts: 3
Re: PCP / ASH script won't run from bootlocal
« Reply #2 on: October 20, 2017, 11:34:16 AM »
Hi Rich,    that doesn't work,  previously tested ko and just redo with the same result  :-[

previous runs was Ko using
- nothing as advised
- Bash and Ash,    as managed with success for python script  (listed just before on the bootlocal.sh file
- the same with full path  as /bin/ash or /bin/bash or /usr/local/bin/bash

thanks for your support !!

below the current bootlocal  / extract
Code: [Select]
/usr/local/etc/init.d/lcdproc-server start
/usr/local/etc/init.d/pikeyd start
/usr/local/etc/init.d/slimmer start
python /usr/local/etc/init.d/shutdown-button.py
/usr/local/etc/init.d/squeezelite_led.sh &

extract of the started processes after booting
Code: [Select]
  877 root     /sbin/udevd --daemon
  895 root     [kworker/2:2]
  946 root     crond
  969 root     {bootlocal.sh} /bin/sh /opt/bootlocal.sh
  970 tc       -sh
 1163 root     /usr/local/sbin/lircd --device=/dev/lirc0 --log=/var/log/pcp_lir
 1231 root     [ipv6_addrconf]
 1252 root     /usr/local/sbin/sshd
 1263 root     /usr/local/bin/squeezelite -n MainPlayer -o hw:CARD=sndrpihifibe
 1298 root     /usr/local/sbin/busybox-httpd -h /home/tc/www
 2716 root     sshd: tc@pts/0
 5144 nobody   /usr/local/sbin/LCDd -c /usr/local/etc/LCDd.conf
 5146 root     /usr/local/sbin/pikeyd -d
 5151 root     /usr/local/bin/slimmer --lmshost 192.168.0.210 --lmsport 9001 --
 5153 root     python /usr/local/etc/init.d/shutdown-button.py
 5155 tc       -sh
 5196 tc       ps

extract of the started processes after manual start of the script
Code: [Select]
  877 root     /sbin/udevd --daemon
  895 root     [kworker/2:2]
  946 root     crond
  969 root     {bootlocal.sh} /bin/sh /opt/bootlocal.sh
  970 tc       -sh
 1163 root     /usr/local/sbin/lircd --device=/dev/lirc0 --log=/var/log/pcp_lirc.log
 1231 root     [ipv6_addrconf]
 1252 root     /usr/local/sbin/sshd
 1263 root     /usr/local/bin/squeezelite -n MainPlayer -o hw:CARD=sndrpihifiberry -a 80 4  1  -i
 1298 root     /usr/local/sbin/busybox-httpd -h /home/tc/www
 2716 root     sshd: tc@pts/0
 5144 nobody   /usr/local/sbin/LCDd -c /usr/local/etc/LCDd.conf
 5146 root     /usr/local/sbin/pikeyd -d
 5151 root     /usr/local/bin/slimmer --lmshost 192.168.0.210 --lmsport 9001 --input /dev/pikeyd
 5153 root     python /usr/local/etc/init.d/shutdown-button.py
 5155 tc       -sh
 5197 root     {squeezelite_led} /bin/ash /usr/local/etc/init.d/squeezelite_led.sh
 5241 root     sleep 1
 5242 tc       ps

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11040
Re: PCP / ASH script won't run from bootlocal
« Reply #3 on: October 20, 2017, 01:22:06 PM »
Perhaps you need to background your python script?
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: PCP / ASH script won't run from bootlocal
« Reply #4 on: October 20, 2017, 01:31:37 PM »
Hi jeff_69_fr
Here's your problem:
Code: [Select]
969 root     {bootlocal.sh} /bin/sh /opt/bootlocal.shOne of your commands doesn't exit and return control to bootlocal, so your squeezelite_led.sh command never gets executed.

Offline jeff_69_fr

  • Newbie
  • *
  • Posts: 3
Re: PCP / ASH script won't run from bootlocal
« Reply #5 on: October 21, 2017, 03:56:52 AM »
Curaga, Rich   thanks you both for your advises

effectively all is now working with the python script in background
Thx again !!

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: PCP / ASH script won't run from bootlocal
« Reply #6 on: October 21, 2017, 06:14:45 PM »
Thanks Tiny Core guys for helping jeff_69_fr out.  :)

hi jeff_69_fr,

Just a little word of warning, as piCorePlayer is not just piCore, sometimes you may be advised to use the "product" forum for support rather than the Tiny Core forums.

regards
Greg

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: PCP / ASH script won't run from bootlocal
« Reply #7 on: October 21, 2017, 07:45:19 PM »
Hi Greg Erskine
Seeing how it wasn't piCorePlayer specific I didn't feel it was out of line, but thanks for passing on the heads up to jeff_69_fr.