fourier_install.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 sqlite3
  59. sudo apt-get install -y portaudio19-dev
  60. sudo apt-get install -y dvb-apps
  61. sudo pip install pyaudio pyusb pydub numpy requests \
  62. scipy python-firebase tornado mutagen \
  63. pyopenssl
  64. sudo apt-get install -y ffmpeg
  65. sudo apt-get install -y gfortran libopenblas-dev liblapack-dev
  66. sudo apt-get install -y python-matplotlib
  67. sudo apt-get install -y curl
  68. sudo apt-get install -y libshout3 libshout3-dev
  69. sudo npm install -g http-server
  70. cd tools
  71. sudo python ./setup.py install
  72. cd ..
  73. sudo chmod 0600 $installerpath/repokey
  74. cd $programspath
  75. clonerepo fourier-module.git module
  76. clonerepo fourier-common.git common
  77. clonerepo fourier-recorder.git recorder
  78. clonerepo fourier-fourier.git fourier
  79. clonerepo fourier-alt.git fourier-alt
  80. clonerepo fourier-monitor.git monitor
  81. clonerepo fourier-uploader.git uploader
  82. clonerepo fourier-ondemand.git ondemand
  83. cd $programspath/recorder
  84. npm install
  85. cd $programspath/monitor
  86. npm install
  87. cd $programspath/uploader
  88. npm install
  89. cd $programspath/module
  90. sudo python setup.py install
  91. cd $programspath/ondemand
  92. sudo python setup.py install
  93. sudo npm install -g pm2
  94. [ ! -f "$configfile" ] && \
  95. sudo python $installerpath/configure.py \
  96. $installerpath/fourier-config.json \
  97. $configfile \
  98. -programs "$programspath" \
  99. -receivers $RECEIVERS_COUNT \
  100. -api-secret $API_SECRET \
  101. -box-id "$BOX_ID"
  102. echo "** Downloading TV channels."
  103. fourier tv update
  104. if [ "$?" -eq 0 ]; then
  105. cd "$programspath"
  106. pm2 start recorder
  107. pm2 start monitor
  108. pm2 start uploader
  109. pm2 start ondemand/ondemand/service.py \
  110. --interpreter=python \
  111. --name=ondemand
  112. cd "$datapath"
  113. pm2 start http-server
  114. cd "$programspath"
  115. pm2 save
  116. pm2 startup
  117. sudo env PATH=$PATH:/usr/bin \
  118. /usr/lib/node_modules/pm2/bin/pm2 \
  119. startup systemd -u fourier \
  120. --hp ~/
  121. fi
  122. if [ ! -f "/etc/systemd/system/ssh-tunnel.service" ]; then
  123. 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
  124. sudo mv $installerpath/ssh-tunnel.service \
  125. /etc/systemd/system/ssh-tunnel.service
  126. sudo systemctl enable ssh-tunnel
  127. sudo systemctl start ssh-tunnel
  128. fi