diff --git a/README.md b/README.md index f15cf71..15d2e9d 100755 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Super Simple Raspberry Pi Audio Receiver Install. -**\*Requires Raspbian Jessie LITE** you can find the lastest Jessie Lite Image [here](http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/)\* +**\*Requires Raspbian Jessie or Raspbian Stretch LITE** you can find the lastest Jessie Lite Image [here](http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/)\* and the latest Stretch lite image [here](https://www.raspberrypi.org/downloads/raspbian/)\* ![SSPARI](https://github.com/BaReinhard/Super-Simple-Raspberry-Pi-Audio-Receiver-Install/blob/master/img/SSRPARI_1080_668.png?raw=true) ## SSPARI v2.0 **_Now Live, includes the following new features:_** +* Raspbian Stretch Support! * Volumio Compatibility for Bluetooth Only - Installs A2DP Bluetooth Streaming to RPI * Backing up of original files * Uninstallation functionality diff --git a/bt_pa_config.sh b/bt_pa_config.sh index d60e7c9..31119f9 100755 --- a/bt_pa_config.sh +++ b/bt_pa_config.sh @@ -22,12 +22,20 @@ then source functions.sh source dependencies.sh fi +if [ -z "$VERSION" ] +then + VERSION=`cat /etc/os-release | grep VERSION= | sed "s/VERSION=//"` + export VERSION +fi + exc sudo cp usr/local/bin/volume-watcher.py /usr/local/bin/volume-watcher.py exc sudo chmod +x /usr/local/bin/volume-watcher.py exc sudo cp lib/systemd/system/volume-watcher.service /lib/systemd/system/volume-watcher.service exc sudo systemctl enable volume-watcher +exc sudo cp lib/systemd/system/systemd-udevd.service /lib/systemd/system/systemd-udevd.service +exc sudo systemctl daemon-reload exc cd `dirname $0` sudo echo "PRETTY_HOSTNAME=$BluetoothName" >> /tmp/machine-info @@ -53,7 +61,13 @@ fi exc sudo chmod +x /etc/init.d/bluetooth-agent exc sudo update-rc.d bluetooth-agent defaults -exc sudo cp usr/local/bin/bluez-udev /usr/local/bin +if [ "$VERSION" = "\"8 (jessie)\"" ] +then + exc sudo cp usr/local/bin/bluez-udev /usr/local/bin +elif [ "$VERSION" = "\"9 (stretch)\"" ] +then + exc sudo cp usr/local/bin/bluez-udev.stretch /usr/local/bin/bluez-udev +fi exc sudo chmod 755 /usr/local/bin/bluez-udev exc sudo cp usr/local/bin/simple-agent.autotrust /usr/local/bin @@ -167,13 +181,6 @@ EOT #sudo service bluetooth-agent start & # BT FIX -exc remove_dir /etc/pulsebackup -exc sudo mkdir /etc/pulsebackup -exc sudo cp /etc/pulse/* /etc/pulsebackup/ - -exc cd ~ -exc remove_dir pulseaudio -exc git clone --branch v6.0 https://github.com/pulseaudio/pulseaudio exc cd ~ exc remove_dir json-c @@ -185,16 +192,38 @@ exc make exc sudo make install exc cd ~ exc remove_dir libsndfile -exc git clone git://github.com/erikd/libsndfile.git +exc git clone https://github.com/erikd/libsndfile.git exc cd libsndfile exc ./autogen.sh exc ./configure --enable-werror exc make exc sudo make install exc cd ~ -exc cd pulseaudio -exc sudo ./bootstrap.sh -exc sudo make -exc sudo make install -exc sudo ldconfig -exc sudo cp /etc/pulsebackup/* /etc/pulse + +if [ "$VERSION" = "\"8 (jessie)\"" ] + then + log "Raspbian Jessie Found" + log "Pulseaudio Version Below v6.0, upgrading from source" + exc remove_dir /etc/pulsebackup + exc sudo mkdir /etc/pulsebackup + exc sudo cp /etc/pulse/* /etc/pulsebackup/ + exc cd ~ + exc remove_dir pulseaudio + exc git clone --branch v6.0 https://github.com/pulseaudio/pulseaudio + exc cd pulseaudio + exc sudo ./bootstrap.sh + exc sudo make + exc sudo make install + exc sudo ldconfig + exc sudo cp /etc/pulsebackup/* /etc/pulse + elif [ "$VERSION" = "\"9 (stretch)\"" ] + then + log "Raspbian Stretch Found" + log "Pulseaudio Version Already Exceeds v6.0" + log "Patching System Daemon" + exc sudo sed -i "s+DAEMON=/usr/local/bin/pulseaudio+DAEMON=/usr/bin/pulseaudio+" /etc/init.d/pulseaudio + exc sudo systemctl daemon-reload + else + log "You are running an unsupported VERSION of RASPBIAN" + fi + diff --git a/bt_pa_install.sh b/bt_pa_install.sh index 7391fee..b3bcbbb 100755 --- a/bt_pa_install.sh +++ b/bt_pa_install.sh @@ -7,8 +7,24 @@ then fi +VERSION=`cat /etc/os-release | grep VERSION= | sed "s/VERSION=//"` +if [ "$VERSION" = "\"8 (jessie)\"" ] +then + log "Raspbian Jessie Found" + for _dep in ${JESSIE_BT_DEPS[@]}; do + apt_install $_dep; + done +elif [ "$VERSION" = "\"9 (stretch)\"" ] +then + log "Raspbian Stretch Found" + for _dep in ${STRETCH_BT_DEPS[@]}; do + apt_install $_dep; + done +else + log "You are running an unsupported VERSION of RASPBIAN" +fi for _dep in ${BT_DEPS[@]}; do apt_install $_dep; done diff --git a/dependencies.sh b/dependencies.sh index 9f504a9..e7add63 100755 --- a/dependencies.sh +++ b/dependencies.sh @@ -1,6 +1,10 @@ #!/bin/bash -BT_DEPS="pulseaudio-module-bluetooth python-dbus libltdl-dev pulseaudio libtool intltool libsndfile-dev libcap-dev libjson0-dev libasound2-dev libavahi-client-dev libbluetooth-dev libglib2.0-dev libsamplerate0-dev libsbc-dev libspeexdsp-dev libssl-dev libtdb-dev libbluetooth-dev intltool autoconf autogen automake build-essential libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev pkg-config python" +BT_DEPS="pulseaudio-module-bluetooth python-dbus libltdl-dev pulseaudio libtool intltool libsndfile-dev libcap-dev libasound2-dev libavahi-client-dev libbluetooth-dev libglib2.0-dev libsamplerate0-dev libsbc-dev libspeexdsp-dev libssl-dev libtdb-dev libbluetooth-dev intltool autoconf autogen automake build-essential libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev pkg-config python" + +JESSIE_BT_DEPS="libjson0-dev" + +STRETCH_BT_DEPS="libjson-c-dev autopoint" VOLUMIO_DEPS="bluez bluez-firmware libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libltdl-dev libsamplerate0-dev libsndfile1-dev libasound2-dev libavahi-client-dev libspeexdsp-dev liborc-0.4-dev intltool libtdb-dev libssl-dev libjson0-dev libsbc-dev libcap-dev" diff --git a/install.sh b/install.sh index baadc10..bf73411 100755 --- a/install.sh +++ b/install.sh @@ -54,9 +54,9 @@ do # Car Installation - Previously Raspberry Pi Audio Receiver Install Car Install AirPlay="y" Bluetooth="y" - AP="y" - Kodi="y" - Lirc="y" + AP="n" + Kodi="n" + Lirc="n" SoundCardInstall="y" GMedia="n" SNAPCAST="n" @@ -67,15 +67,17 @@ do AirPlay="y" Bluetooth="y" AP="n" - Kodi="y" - Lirc="y" + Kodi="n" + Lirc="n" SoundCardInstall="y" - GMedia="y" + GMedia="n" SNAPCAST="n" break ;; 3) # Access Point Install - Previously Network Without Internet + log "AP is not supported yet" + exit AirPlay="n" Bluetooth="n" AP="y" @@ -121,18 +123,18 @@ do # Prompts the User to use the Raspberry Pi as an Access Point to create a network # (needed for AirPlay when no existing network exists) AP="n" - YesNo "Do you want to setup as an Access Point? (Necessary for AirPlay, in location without a Wireless Network) (y/n) : " && AP="y" + #YesNo "Do you want to setup as an Access Point? (Necessary for AirPlay, in location without a Wireless Network) (y/n) : " && AP="y" # Prompts the User to use Kodi as a GUI for a Media Center Kodi="n" - YesNo "Do you want Kodi installed? (y/n) : " && Kodi="y" + #YesNo "Do you want Kodi installed? (y/n) : " && Kodi="y" # Prompts the User to use Lirc for Infrared Remote Support # (matricom IR remote already setup for use with Kodi) Lirc="n" - YesNo "Do you want to use infrared remotes? (y/n) : " && Lirc="y" + #YesNo "Do you want to use infrared remotes? (y/n) : " && Lirc="y" SoundCardInstall="n" YesNo "Do you want to use a Sound Card? (y/n) : " && SoundCardInstall="y" GMedia="n" - YesNo "Do you want to setup device as a UPnP Renderer? (y/n) : " && GMedia="y" + #YesNo "Do you want to setup device as a UPnP Renderer? (y/n) : " && GMedia="y" break ;; *) @@ -262,9 +264,9 @@ chmod +x ./*.sh # Updates and Upgrades the Raspberry Pi log "Updating via Apt-Get" -apt-get update -y &> /dev/null +apt-get update -y log "Upgrading via Apt-Get" -apt-get upgrade -y &> /dev/null +apt-get upgrade -y # If Bluetooth is Chosen, it installs Bluetooth Dependencies and issues commands for proper configuration diff --git a/lib/systemd/system/systemd-udevd.service b/lib/systemd/system/systemd-udevd.service new file mode 100644 index 0000000..39607dd --- /dev/null +++ b/lib/systemd/system/systemd-udevd.service @@ -0,0 +1,30 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=udev Kernel Device Manager +Documentation=man:systemd-udevd.service(8) man:udev(7) +DefaultDependencies=no +Wants=systemd-udevd-control.socket systemd-udevd-kernel.socket +After=systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-sysusers.service +Before=sysinit.target +ConditionPathIsReadWrite=/sys + +[Service] +Type=notify +OOMScoreAdjust=-1000 +Sockets=systemd-udevd-control.socket systemd-udevd-kernel.socket +Restart=always +RestartSec=0 +ExecStart=/lib/systemd/systemd-udevd +#KillMode=mixed +#WatchdogSec=3min +#TasksMax=infinity +#MountFlags=slave +#MemoryDenyWriteExecute=yes +#RestrictRealtime=yes +#RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6 \ No newline at end of file diff --git a/sound_card_install.sh b/sound_card_install.sh index 961f892..c17676e 100755 --- a/sound_card_install.sh +++ b/sound_card_install.sh @@ -46,11 +46,9 @@ save_original /etc/asound.conf sudo cat << EOT >> /etc/asound.conf pcm.pulse { type pulse - card 0 } ctl.pulse { type pulse - card 0 } pcm.!default { diff --git a/ssrpari_bluetooth.zip b/ssrpari_bluetooth.zip new file mode 100644 index 0000000..66f6f54 Binary files /dev/null and b/ssrpari_bluetooth.zip differ diff --git a/usr/local/bin/bluez-udev.stretch b/usr/local/bin/bluez-udev.stretch new file mode 100755 index 0000000..031b93e --- /dev/null +++ b/usr/local/bin/bluez-udev.stretch @@ -0,0 +1,61 @@ +#!/bin/bash +audio_sink=0 +name=$(sed 's/\"//g' <<< $NAME) +#exit if not a BT address +if [[ ! $name =~ ^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$ ]]; then exit 0; fi + +bt_name=`grep Name /var/lib/bluetooth/*/$name/info | awk -F'=' '{print $2}'` +#sudo pkill arecord # Uncomment for Audio Line Input +audio_source=bluez_source.$(sed 's/:/_/g' <<< $name) +audio_source="$audio_source.a2dp_source" +action=$(expr "$ACTION" : "\([a-zA-Z]\+\).*") +logger "Action: $action" +if [ "$action" = "add" ]; then + logger "[$(basename $0)] Bluetooth device is being added [$name] - $bt_name" + logger "[$(basename $0)] Patching $audio_source into ALSA sink #$audio_sink" + #hciconfig hci0 noscan + bluetoothctl << EOT +discoverable off +EOT + amixer cset numid=3 1 + amixer cset numid=3 50% + #espeak -s 160 -k 1 "Device, $bt_name Connected" + /usr/local/bin/say.sh "Device, $bt_name Connected" + amixer cset numid=3 90% + sleep 1 + pactl set-sink-volume 0 65537 + pactl set-source-volume $audio_source 90% + + + + # loop back this source to the default sink + sleep 2s + handle=$(pactl load-module module-loopback source=$audio_source sink=$audio_sink) + logger "[$(basename $0)] PulseAudio module-loopback returned handle [$handle]" + logger "$bt_name" + + +fi + +if [ "$action" = "remove" ]; then + logger "[$(basename $0)] Bluetooth device is being removed [$name] - $bt_name" + #hciconfig hci0 pscan + + bluetoothctl << EOT +discoverable on +EOT + + # remove any loopback modules assigned to this source + # only required for USB sound cards, which PulseAudio will not automatically remove + for handle in $(pactl list short modules | grep module-loopback | grep source=$audio_source | cut -f 1); do + logger "[$(basename $0)] Unloading module-loopback with handle [$handle]" + pactl unload-module $handle + done + + #arecord -D plughw:1 -f dat | aplay -D plughw:1 -f dat& # Uncomment for Audio Line Input + sleep 5 + amixer cset numid=3 80% + #espeak -s 160 -k 1 "Device, $bt_name Disconnected" + /usr/local/bin/say.sh "Device, $bt_name Disconnected" + amixer cset numid=3 80% +fi