I made a script to reproduce my install in case I will need it in the future.
The script has all I need and contains suggestions, for example about the NAS share mounting.
No guarantee.
#!/bin/bash
echo Step 1
echo NAS settings in GUI or manually
echo The share name MUST be lowercase
echo Options are:
echo ro,noatime,sec=ntlmv2
read -r -p "Press any key to continue..." arg
echo Step 2a
echo Disable unwanted SMB shares, make others not public
read -r -p "Press any key to continue..." arg
nano /var/www/_OS_SETTINGS/etc/samba/smb.conf
cp -f /var/www/_OS_SETTINGS/etc/samba/smb.conf /etc/samba/smb.conf
echo Step 2b
echo Disable Samba altogether
read -r -p "Press any key to continue..." arg
mkdir /etc/init.disabled
mv /etc/init.d/samba /etc/init.disabled/
echo Step 3
echo Disable USB automount
read -r -p "Press any key to continue..." arg
nano /var/www/_OS_SETTINGS/etc/usbmount/usbmount.conf
cp -f /var/www/_OS_SETTINGS/etc/usbmount/usbmount.conf /etc/usbmount/usbmount.conf
echo Step 4
echo Disable ramdisk
read -r -p "Press any key to continue..." arg
nano /var/www/_OS_SETTINGS/etc/fstab_raspberry
cp -f /var/www/_OS_SETTINGS/etc/fstab_raspberry /etc/fstab_raspberry
cp -f /var/www/_OS_SETTINGS/etc/fstab_raspberry /etc/fstab
echo Step 5
echo 'Check correct "mixer_control" (PCM?)'
read -r -p "Press any key to continue..." arg
nano /etc/mpd.conf
echo Step 6a
echo Install 'expect'
read -r -p "Press any key to continue..." arg
apt-get update
apt-get install expect
echo Step 6b
echo Decompress GPIO scripts in /usr/local/bin
read -r -p "Press any key to continue..." arg
tar xvf gpio.tar.bz2 -C /usr/local/bin/
echo Step 7
echo Modify /etc/init.d/shairport start command line:
echo '-B "mpc stop && /usr/local/bin/gpio/poweron.sh" -E "/usr/local/bin/gpio/poweroff.sh"'
read -r -p "Press any key to continue..." arg
nano /etc/init.d/shairport
# it works but I get:
# WARNING: exec of external start command failed
# WARNING: exec of external stop command failed
echo Step 8
echo Decompress llctl bin in /usr/local/bin
read -r -p "Press any key to continue..." arg
tar xvf llctl.tar.bz2 -C /usr/local/bin/
echo Step 9
echo 'Add following lines before "exit 0" in rc.local'
echo '/usr/local/bin/llctl/llctl f0'
echo '/usr/local/bin/llctl/llctl l0'
echo '/usr/local/bin/llctl/llctl d0'
echo 'echo "23" > /sys/class/gpio/export'
echo 'echo "out" > /sys/class/gpio/gpio23/direction'
echo 'echo "0" > /sys/class/gpio/gpio23/value'
echo '/usr/local/bin/gpio/handle_speakers.sh > /dev/null 2>&1 < /dev/null &'
echo 'disown'
read -r -p "Press any key to continue..." arg
nano /var/www/_OS_SETTINGS/etc/rc.local
cp -f /var/www/_OS_SETTINGS/etc/rc.local /etc/rc.local
echo Step 10
echo Disable force_turbo
read -r -p "Press any key to continue..." arg
nano /var/www/_OS_SETTINGS/boot/cmdline.txt
cp -f /var/www/_OS_SETTINGS/boot/cmdline.txt /boot/cmdline.txt
echo Step 11
echo Expand partition of SD card
read -r -p "Press any key to continue..." arg
raspi-config
echo Step 12
echo Disable/uninstall useless services
mkdir /etc/init.disabled
mv /etc/init.d/exim4 /etc/init.disabled/
mv /etc/init.d/rsync /etc/init.disabled/
apt-get remove wireless-tools wpasupplicant samba samba-common samba-common-bin rsync ntfs-3g mutt exim4
echo Update firmware R-Pi
apt-get install binutils
rpi-update
echo Step 13
echo Change passwords
echo 'for user "pi"'
read -p "Press any key to continue..."
passwd pi
echo 'for user "volumio"'
read -p "Press any key to continue..."
passwd volumio
echo 'for user "root"'
read -p "Press any key to continue..."
passwd root
Where gpio.tar.bz2 contains:
handle_speakers.sh
#!/usr/bin/expect --
set timeoff 600
set server localhost
set port 6600
#set onplay [lindex $argv 2]
set onplay /home/pi/gpio/poweron.sh
#set noplay [lindex $argv 3]
set noplay /home/pi/gpio/poweroff.sh
#set onstop [lindex $argv 3]
set timeout -1
log_user 0
trap {send "close\r"
exit} {SIGINT SIGTERM}
#send_user "Starting connection to MPD [lrange $argv 0 1]\r\n"
#send_user "On play: $onplay\r\n"
#send_user "On no play: $noplay\r\n"
#send_user "On stop: $onstop\r\n"
#spawn -noecho telnet [lindex $argv 0] [lindex $argv 1]
spawn -noecho telnet $server $port
expect {
"OK MPD" {
# send_user "Connected\r\n"
}
}
send "status\r"
expect {
"state: play" {
set currentState "play"
}
"state: pause" {
set currentState "noplay"
}
"state: stop" {
set currentState "noplay"
}
}
#send_user "Initial state $currentState\r\n"
send "idle player\r"
for {} 1 {} {
expect {
timeout {
if { "$noplay" != "" } {
exec "$noplay"
}
# send_user "Timeout, off speakers\r\n"
set timeout -1
}
"changed: player" {
# send_user "Changed status player\r\n"
send "status\r"
}
"state: play" {
# send_user "Status: play\r\n"
if { "$currentState" != "play" } {
# send_user "State changed to play\r\n"
if { "$onplay" != "" } {
exec $onplay
}
set timeout -1
set currentState "play"
}
send "idle player\r"
}
"state: pause" {
# send_user "Status: pause\r\n"
if { "$currentState" != "noplay" } {
# send_user "State changed to pause\r\n"
set timeout $timeoff
set currentState "stop"
}
send "idle player\r"
}
"state: stop" {
# send_user "Status: stop\r\n"
if { "$currentState" != "noplay" } {
# send_user "State changed to stop\r\n"
set timeout $timeoff
set currentState "stop"
}
send "idle player\r"
}
}
}
poweron.sh
echo "1" > /sys/class/gpio/gpio23/value
poweroff.sh
echo "0" > /sys/class/gpio/gpio23/value
Good luck.