install.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. set -e
  3. BASE=/home/pi
  4. GIT_NAME=bt-speaker
  5. GIT_FOLDER="$BASE/$GIT_NAME"
  6. echo "Installing dependencies..."
  7. apt update
  8. apt -y install bluealsa git vorbis-tools
  9. echo "Done"
  10. echo
  11. cd $BASE
  12. echo "Cloning project"
  13. if [ -d $GIT_NAME ]; then
  14. echo "Updating bt-speaker"
  15. cd $GIT_NAME && git pull && git checkout ${1:master}
  16. else
  17. echo "Downloading bt-speaker..."
  18. git clone https://glitter.jemoeders.website/biodiscus/bt-speaker.git
  19. cd $GIT_NAME && git checkout ${1:master}
  20. fi
  21. echo "Done"
  22. echo "Installing the services"
  23. cd $GIT_FOLDER
  24. for file in $GIT_FOLDER/service/*
  25. do
  26. systemctl enable $file
  27. NAME=$(basename -- "$file")
  28. if [ "`systemctl is-active $NAME`" != "active" ]; then
  29. systemctl start $NAME
  30. else
  31. systemctl restart $NAME
  32. fi
  33. done
  34. echo "Done"
  35. echo "Fix permissions on the autoconnect script"
  36. chmod +x $GIT_FOLDER/scripts/autoconnect
  37. echo "Done"
  38. echo "Fixing bluealsa to use a2dp-sink"
  39. sed -i "s/\/usr\/bin\/bluealsa/\/usr\/bin\/bluealsa -p a2dp-sink/g" /lib/systemd/system/bluealsa.service
  40. echo "Done"
  41. # Set the machine name, which is the name that will be shown when looking for Bluetooth devices
  42. echo
  43. echo "Setting the machine info "
  44. echo "PRETTY_HOSTNAME=Dikke BMW" >> /etc/machine-info
  45. echo "Done"
  46. # Set the audio level to something reasonable
  47. # 85% because anything higher than that gives a strange 'crackle'
  48. amixer sset 'PCM' 85%
  49. # Finished
  50. echo
  51. echo "BT-Speaker has been installed. Rebooting in 5 seconds"
  52. sleep 5
  53. reboot