Skip to content

Commit

Permalink
Startup script enhancements.
Browse files Browse the repository at this point in the history
- Add a work-around for audio issues in older Raspberry firmware.
  raspberrypi/linux#570

- Move a few things around to give DHCP a little more time to come
  up before we log/announce the IP addresses.  This way we're doing
  something rather than just waiting in WaitForDHCPIPs for the IP(s)
  to come up.

- Disable wifi interface by default on stock SD image so that
  WaitForDHCPIPs doesn't wait 60 seconds for it to get an IP address.
  When users configure wifi via the Network Config screen, we'll
  detect that and wait for an IP to come up on the wireless interface.

- Execute flite in the background so that we can proceed with bootup
  while it announces our IP addresses.  Shaves another few seconds off
  our boot time.
  • Loading branch information
cpinkham committed Jun 4, 2014
1 parent e5d5442 commit cc66414
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions scripts/startup
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,54 @@ cp ${FPPDIR}/etc/php.ini /etc/php5/apache2/php.ini
# If the flash drive is not mounted yet, then fix Apache so it can at least start up
if [ ! -d "/home/pi/media/logs" ]
then
perl -pi -e "s/ErrorLog.*/ErrorLog \/var\/tmp\/apache-error.log/" /etc/apache2/sites-available/default
sed -i "s/ErrorLog/#ErrorLog/" /etc/apache2/sites-available/default
/etc/rc2.d/S02apache2 restart
fi

# Configure Network and DNS
${BINDIR}/config_network
${BINDIR}/config_dns

WaitForDHCPIPs
###########################################################################
# Part #1 of workaround for https://github.com/raspberrypi/linux/issues/570
# Play some silence while we set the volume so the new value will stick
mpg123 /opt/fpp/media/silence.mp3 > /dev/null 2>&1 &
SILENCEPID=$!
###########################################################################

amixer cset numid=3 1
ORIGVOLUME=$(getSetting volume)
# Switch to this more accurate setting for or after v0.3.0
#VOLUME=$(echo "scale=2 ; ${ORIGVOLUME} / 2 + 50" | bc)
VOLUME=$(expr ${ORIGVOLUME} / 2 + 50)
amixer set PCM ${VOLUME}%

###########################################################################
# Part #2 of workaround for https://github.com/raspberrypi/linux/issues/570
sleep 1
kill -9 ${SILENCEPID}
###########################################################################

# Let's check that our .asoundrc is as valid as we care about right now
if [ ! -e /proc/asound/card$(sed -n '/card [0-9]*/p' /root/.asoundrc | head -n 1 | awk '{print $2}') ]; then
echo "Configured sound card might not exist, let's set it to 0 as a default."
sed -i 's/card [0-9]/card 0/' /root/.asoundrc
fi

sysctl net/ipv4/igmp_max_memberships=150
/usr/local/bin/gpio load spi 100

${BINDIR}/piRTC

# Make sure our DHCP IPs are up before we log/announce them.
WaitForDHCPIPs

# Print/Say the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
arrHost=(${_IP// / })
flite -voice kal "I Have Found The Following I P Addresses, ${arrHost[0]}, ${arrHost[1]}, ${arrHost[2]}"
flite -voice kal "I Have Found The Following I P Addresses, ${arrHost[0]}, ${arrHost[1]}, ${arrHost[2]}" &
fi

# Check for flash drive mounted
Expand Down Expand Up @@ -76,16 +97,9 @@ else
fi
done

sysctl net/ipv4/igmp_max_memberships=150
/usr/local/bin/gpio load spi 100

# mpg123 ${FPPDIR}/bin/silence.mp3 > /dev/null

sed -e "s#FPPDIR#${FPPDIR}#g" < ${FPPDIR}/etc/apache2.site > /etc/apache2/sites-available/default
/etc/rc2.d/S02apache2 restart

${BINDIR}/piRTC

${BINDIR}/fpp_boot

PiLCDenabled=$(awk -f ${FPPDIR}/scripts/readSetting.awk /home/pi/media/settings setting=PI_LCD_Enabled)
Expand All @@ -110,7 +124,7 @@ else
setterm -blank 0
fi

# Sleep for just a little while so the use can see the login prompt before
# Sleep for just a little while so the user can see the login prompt before
# we display the logo
(sleep 60 ; /usr/bin/fbi -T 1 -noverbose -a /etc/splash.png) &

0 comments on commit cc66414

Please sign in to comment.