Bogg wrote: 
> When I boot with dac off sqlite does not start.
> When I then turn on the dac sqlite still does not start.
> When I then restart sqlite from command line sqlite starts.

I can't understand this behaviour at all.  There's nothing in the
'restart' part of the script that relies on previously discovering the
DAC, or any other variables etc - it simply issues the restart command. 
And your log files confirm that it's clearly issuing the command - the
exact same command that you issue from the command line - because the
multiple "Squeezelite is not running.  Starting Squeezelite player:
Squeezelite..." lines in the log file are the responses to that restart
command (the $result in the script below).

So why does this command work when called from the command line, but not
when called by the script?

Here's the bit of the script that issues the restart command, in case
anyone else has any bright ideas.

Code:
--------------------
    SQLITErestart() {
        local logfile=$1
        local attempts=5 # number of tries
        local interval=1 # interval between tries (seconds)
        
        local count=$attempts 
        status="Squeezelite not running."
        while [ "$status" == "Squeezelite not running." ]; do
                if [ $((count--)) -le 0 ]; then
                        log  "Squeezelite failed to initialize within $attempts 
attempts." $logfile
                        exit 1 
                fi
                result="$(sudo /usr/local/etc/init.d/squeezelite restart)"
                log "$result" $logfile
                sleep $interval
                status="$(sudo /usr/local/etc/init.d/squeezelite status)"
                log "$status" $logfile
        done
        # determine cardname from squeezelite process id
        local PID=$(sudo /usr/local/etc/init.d/squeezelite status | awk -F PID= 
{'print $2'})
        local cardname=$(ps | grep $PID | awk -F CARD= {'print $2'} | awk -F , 
{'print $1'})
        log "Restoring alsa settings for $cardname" $logfile
        sudo /usr/local/sbin/alsactl restore $cardname
  }
--------------------


I've just noticed that I did not declare $result or $status to be a
local variables inside the SQLITErestart() function.  I wonder what the
effect of that is in this case, where the main script that spawned this
SQLITErestart() function into the background, has already finished some
seconds ago.  Perhaps you could add 'local result' and 'local status' to
the beginning of this function, where all the other local variables are
declared.  I don't believe this is causing your issue, since the command
is evidently being issued anyway, but you never know!


------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=113661

_______________________________________________
unix mailing list
unix@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to