fourier_install.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # version 1.0.4
  2. # install essential software
  3. # sudo apt-get update
  4. installer_version=1.0.4
  5. programspath=~/programs
  6. installerpath=$(pwd)
  7. configfile='/etc/fourier-config.json'
  8. gitbase="gogs@git.miralo.xyz:AudioValid"
  9. tunnel_user=rtunnel
  10. datapath='/var/fourier'
  11. serverhost='monitor.audiovalid.com'
  12. tunnelfile="$programspath/ssh-tunnel.sh"
  13. mysql_user=fourier
  14. mysql_passwd='Sup3rDuper!'
  15. mysql_db=fourier
  16. mount_point=/media/datadrive
  17. echo "Fourier installer $installer_version"
  18. echo "------------------------------------"
  19. clonerepo() {
  20. GIT_SSH_COMMAND="ssh -i $installerpath/repokey -o StrictHostKeychecking=no" \
  21. git clone $gitbase/$1 $2
  22. }
  23. [ ! -d "$programspath" ] && mkdir $programspath
  24. read -p "Whats this box port (last 3 numbers with zero for padding)? " PORT
  25. read -p "How many receivers has this box? " RECEIVERS_COUNT
  26. read -p "Box ID: " BOX_ID
  27. read -p "API secret: " API_SECRET
  28. sudo apt-get install -y python python-pip python-setuptools
  29. findmnt "$mount_point"
  30. if [ "$?" -neq 0 ]; then
  31. echo -e 'Data drive is not mounted'
  32. fi
  33. keyspath=~/.ssh
  34. keyfile="$keyspath/id_rsa"
  35. [ ! -d "$keyspath" ] && mkdir $keyspath
  36. ssh-keygen -t rsa -b 2048 -C "$HOSTNAME" -P "" -f $keyfile
  37. keycontent=$(cat $keyfile.pub)
  38. curl -X POST -F "key=$keycontent" \
  39. -H "Authorization: $BOX_ID $API_SECRET" \
  40. https://api.audiovalid.com/public-key
  41. # Give permissions to tune DVB devices
  42. # So it can use the devices in /dev/dvb/adapter*
  43. sudo usermod -a -G video fourier
  44. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  45. sudo apt-get install -y alsa-utils alsa-tools
  46. sudo apt-get install -y libudev-dev
  47. sudo apt-get install -y tmux
  48. sudo apt-get install -y vim
  49. sudo apt-get install -y autossh
  50. sudo apt-get install -y git-core
  51. sudo apt-get install -y build-essential
  52. sudo apt-get install -y nodejs
  53. sudo apt-get install -y python-dev
  54. sudo apt-get install -y lame
  55. sudo apt-get install -y ezstream
  56. sudo apt-get install -y cmake
  57. # sudo apt-get install -y rtl-sdr
  58. sudo apt-get install -y libusb-1.0-0-dev
  59. sudo apt-get install -y sqlite3
  60. sudo apt-get install -y portaudio19-dev
  61. sudo apt-get install -y dvb-apps
  62. sudo pip install pyaudio pyusb pydub numpy requests \
  63. scipy python-firebase tornado mutagen \
  64. pyopenssl google-auth
  65. sudo apt-get install -y ffmpeg
  66. sudo apt-get install -y gfortran libopenblas-dev liblapack-dev
  67. sudo apt-get install -y python-matplotlib
  68. sudo apt-get install -y curl
  69. sudo apt-get install -y libshout3 libshout3-dev
  70. sudo npm install -g http-server
  71. cd tools
  72. sudo python ./setup.py install
  73. cd ..
  74. sudo chmod 0600 $installerpath/repokey
  75. cd $installerpath
  76. sudo mv fourier-key.json /etc/Fourier-key.json
  77. cd $programspath
  78. clonerepo fourier-module.git module
  79. clonerepo fourier-common.git common
  80. clonerepo fourier-recorder.git recorder
  81. clonerepo fourier-fourier.git fourier
  82. clonerepo fourier-alt.git fourier-alt
  83. clonerepo fourier-monitor.git monitor
  84. clonerepo fourier-uploader.git uploader
  85. clonerepo fourier-ondemand.git ondemand
  86. clonerepo rtl-sdr.git rtl-sdr
  87. cd $programspath/recorder
  88. npm install
  89. cd $programspath/monitor
  90. npm install
  91. cd $programspath/uploader
  92. npm install
  93. cd $programspath/module
  94. sudo python setup.py install
  95. cd $programspath/ondemand
  96. sudo python setup.py install
  97. # Build sdr library
  98. cd $programspath/rtl-sdr
  99. mkdir build
  100. cd build
  101. cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
  102. make
  103. sudo cp ./src/rtl_fm /usr/bin/rtl_fm
  104. #sudo make install
  105. echo "SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", MODE:="0666"" | sudo tee -a /etc/udev/rules.d/rtl-sdr.rules
  106. sudo npm install -g pm2
  107. [ ! -f "$configfile" ] && \
  108. sudo python $installerpath/configure.py \
  109. $installerpath/fourier-config.json \
  110. $configfile \
  111. -programs "$programspath" \
  112. -receivers $RECEIVERS_COUNT \
  113. -api-secret $API_SECRET \
  114. -box-id "$BOX_ID"
  115. echo "** Downloading TV channels."
  116. fourier tv update
  117. if [ "$?" -eq 0 ]; then
  118. cd "$programspath"
  119. pm2 start recorder
  120. pm2 start monitor
  121. pm2 start uploader
  122. pm2 start ondemand/ondemand/service.py \
  123. --interpreter=python \
  124. --name=ondemand
  125. cd "$datapath"
  126. pm2 start http-server
  127. cd "$programspath"
  128. pm2 save
  129. pm2 startup
  130. sudo env PATH=$PATH:/usr/bin \
  131. /usr/lib/node_modules/pm2/bin/pm2 \
  132. startup systemd -u fourier \
  133. --hp ~/
  134. fi
  135. if [ ! -f "/etc/systemd/system/ssh-tunnel.service" ]; then
  136. echo "/usr/bin/autossh -N -f -M 7$PORT -oPubkeyAuthentication=yes -oPasswordAuthentication=no -oLogLevel=error -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i $keyfile -R 6$PORT:localhost:22 $tunnel_user@$serverhost -p 22" > $tunnelfile
  137. sudo mv $installerpath/ssh-tunnel.service \
  138. /etc/systemd/system/ssh-tunnel.service
  139. sudo systemctl enable ssh-tunnel
  140. sudo systemctl start ssh-tunnel
  141. fi