Hello,
to start the player after "hard boot" I modified the "squeezelite_initd"
file.
Before - you have to setup following settings (over your piCorePlayer
WEB interface):
a) NAME of your piCorePlayer
b) ServerIP of your SqueezeServer
c) MAC address of your piCorePlayer
After all don't forget to backup your squeezelite_initd with:
"*filetool.sh -b*"
For me it works.
Best regards
--->
#!/bin/sh
#If no config file is provided, the options can be given here, like:
#OUTPUT='-o default:CARD=ALSA'
#NAME='-n SqueezelitePlayerName'
#ETC...
#Read from config file..
#. /mnt/mmcblk0p1/tce/OliWeb-master/ivySox/picocgi/Config.cfg
. /usr/local/sbin/config.cfg
# SQUEEZEBOX SERVER PORT FOR SENDING PLAY AND POWER OFF COMMANDS
SB_SERVER_CLI_PORT=\"9090\"
#Check if variable is present and then add the correct option in front
if [[ X"" = X"$NAME" ]]; then *SL_NAME="$NAME";* NAME=""; else NAME="-n
$NAME"; fi
if [[ X"" = X"$OUTPUT" ]]; then OUTPUT=""; else OUTPUT="-o $OUTPUT"; fi
if [[ X"" = X"$ALSA_PARAMS" ]]; then ALSA_PARAMS=""; else
ALSA_PARAMS="-a $ALSA_PARAMS"; fi
if [[ X"" = X"$BUFFER_SIZE" ]]; then BUFFER_SIZE=""; else
BUFFER_SIZE="-b $BUFFER_SIZE"; fi
if [[ X"" = X"$_CODEC" ]]; then _CODEC=""; else _CODEC="-c $_CODEC"; fi
if [[ X"" = X"$PRIORITY" ]]; then PRIORITY=""; else PRIORITY="-p
$PRIORITY"; fi
if [[ X"" = X"$MAX_RATE" ]]; then MAX_RATE=""; else MAX_RATE="-r
$MAX_RATE"; fi
if [[ X"" = X"$UPSAMPLE" ]]; then UPSAMPLE=""; else UPSAMPLE="-R
$UPSAMPLE"; fi
if [[ X"" = X"$MAC_ADDRESS" ]]; then MAC_ADDRESS=""; else
*SL_MAC_ADDRESS="$MAC_ADDRESS";* MAC_ADDRESS="-m $MAC_ADDRESS"; fi
if [[ X"" = X"$SERVER_IP" ]]; then SERVER_IP=""; else
*SB_SERVER_IP="$SERVER_IP";* SERVER_IP="-s $SERVER_IP"; fi
if [[ X"" = X"$LOGLEVEL" ]]; then LOGLEVEL=""; else LOGLEVEL="-d
$LOGLEVEL"; fi
if [[ X"" = X"$DSDOUT" ]]; then DSDOUT=""; else DSDOUT="-D $DSDOUT"; fi
if [[ X"" = X"$VISULIZER" ]]; then VISULIZER=""; else VISULIZER="-V
$VISULIZER"; fi
if [[ X"" = X"$OTHER" ]]; then OTHER=""; else OTHER="$OTHER"; fi
if [[ X"" = X"$LOGFILE" ]]; then LOGFILE=""; else LOGFILE="-f
/mnt/sda1/$LOGFILE"; fi
#echo "strings er:" $NAME $OUTPUT $ALSA_PARAMS $BUFFER_SIZE $PRIORITY
$MAX_RATE $UPSAMPLE $MAC_ADDRESS $SERVER_IP $LOGLEVEL $LOGFILE $DSDOUT
$VISULIZER $OTHER
#
# Function that starts the daemon/service
#
do_start()
{
start-stop-daemon --start --quiet -b -m -p/var/run/squeezelitehf.pid
--exec /mnt/mmcblk0p2/tce/squeezelite-armv6hf -- $NAME $OUTPUT
$ALSA_PARAMS $BUFFER_SIZE $_CODEC $PRIORITY $MAX_RATE $UPSAMPLE
$MAC_ADDRESS $SERVER_IP $LOGLEVEL $LOGFILE $OTHER $VISULIZER $DSDOUT
# next commands can only be done if Squeezebox server IP is set
if [ ! -z "$SB_SERVER_IP" ]; then
echo "Wait until player is connected to Squeezebox server before
sending play command"
for i in $(seq 1 10)
do
PLAYERCONNECTED=$(printf "$SL_NAME connected ?\nexit\n" | nc
$SB_SERVER_IP $SB_SERVER_CLI_PORT | tr -s ' '| cut -d ' ' -f3)
if [ "$PLAYERCONNECTED" == "1" ]
then
echo "Player connected to Squeezebox server after $i seconds"
break
fi
echo "Not connected after $i seconds..."
sleep 1
done
if [ "$PLAYERCONNECTED" == "1" ]
then
# connected
# First send power-on command to squeezebox server
echo "Sending power on command for player ${SL_NAME}
(${SL_MAC_ADDRESS}) to Squeezebox server (${SB_SERVER_IP}
${SB_SERVER_CLI_PORT})"
printf "$SL_MAC_ADDRESS power 1\nexit\n" | nc $SB_SERVER_IP
$SB_SERVER_CLI_PORT > /dev/null
# start do_play
do_play
else
echo "Could not send play command to player $SL_NAME on
Squeezebox server $SB_SERVER_IP"
fi
fi
}
#
# Function for telling the player to start playing at a certain volume
(optional)
#
# cronjob:
#0 7 * * 1-5 sudo /etc/init.d/squeezelite play 40
#
do_play()
{
VOLUME=$1
# This function only works if the Squeezebox server IP is set
if [ ! -z "$SB_SERVER_IP" ]; then
echo "Sending play command to Squeezebox server"
printf "$SL_NAME play\nexit\n" | nc $SB_SERVER_IP
$SB_SERVER_CLI_PORT > /dev/null
if [ ! -z "$1" ]; then
# volume has to be set
do_set_volume "$VOLUME"
fi
else
echo "The IP address of the Squeezebox server is not set
(variable: SB_SERVER_IP should be set)."
echo " This is needed for the do_play function."
fi
}
#
# Function to set the volume
#
# cronjob:
#0 7 * * 1-5 sudo /etc/init.d/squeezelite set_volume 40
#
do_set_volume()
{
VOLUME=$1
# This function only works if the Squeezebox server IP is set
if [ ! -z "$SB_SERVER_IP" ]; then
if [ ! -z "$1" ]; then
# volume has to be set
printf "$SL_NAME mixer volume ${VOLUME}\nexit\n" | nc
$SB_SERVER_IP $SB_SERVER_CLI_PORT
else
echo "ERROR: set_volume needs a volume as a parameter, for
example: /etc/init.d/squeezelite set_volume 40"
fi
else
echo "The IP address of the Squeezebox server is not set
(variable: SB_SERVER_IP should be set)."
echo "This is needed for the do_set_volume function."
fi
}
#
# main
#
case "$1" in
start)
echo "Starting Squeezelite"
do_start
;;
stop)
echo "Stopping Squeezelite"
start-stop-daemon --stop --quiet --pidfile
/var/run/squeezelitehf.pid
sudo rm -f /var/run/squeezelitehf.pid
;;
*)
echo "Usage: /usr/local/etc/init.d/squeezelitehf {start|stop}"
exit 1
;;
esac
exit 0
<---
------------------------------------------------------------------------
hdhwx42's Profile: http://forums.slimdevices.com/member.php?userid=63810
View this thread: http://forums.slimdevices.com/showthread.php?t=97803
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix