fourier_install.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # version 1.0.2
  2. # install essential software
  3. # sudo apt-get update
  4. installer_version=1.0.3
  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. sudo apt-get install python python-pip
  20. if [[ "$OSTYPE" == darwin* ]]; then
  21. programspath=~/fourier
  22. fi
  23. clonerepo() {
  24. GIT_SSH_COMMAND="ssh -i $installerpath/repokey -o StrictHostKeychecking=no" \
  25. git clone $gitbase/$1 $2
  26. }
  27. [ ! -d "$programspath" ] && mkdir $programspath
  28. read -p "Whats this box port (last 3 numbers with zero for padding)? " PORT
  29. read -p "How many receivers has this box? " RECEIVERS_COUNT
  30. read -p "Box ID (from API): " BOX_ID
  31. read -p "API secret: " API_SECRET
  32. if [[ "$OSTYPE" == darwin* ]]; then
  33. keyfile="$programspath/fourier.key"
  34. [ ! -f "$keyfile" ] && ssh-keygen -t rsa -b 2048 -f $keyfile
  35. else
  36. keyspath=~/.ssh
  37. keyfile="$keyspath/id_rsa"
  38. [ ! -d "$keyspath" ] && mkdir $keyspath
  39. ssh-keygen -t rsa -b 2048 -C "$HOSTNAME" -f $keyfile
  40. fi
  41. echo -e "\e[33mPlease add the following public key to server's authorized keys:\e[0m"
  42. cat $keyfile.pub
  43. read -p "Press enter to continue"
  44. if [[ "$OSTYPE" != darwin* ]]; then
  45. 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
  46. sudo mv $installerpath/ssh-tunnel.service /etc/systemd/system/ssh-tunnel.service
  47. sudo systemctl enable ssh-tunnel
  48. sudo systemctl start ssh-tunnel
  49. fi
  50. if [[ "$OSTYPE" == darwin* ]]; then
  51. depend=( python gcc vim tmux autossh lame nodejs \
  52. ezstream libusb rtl-sdr portaudio )
  53. for dep in "${depend[@]}"
  54. do
  55. brew list $dep > /dev/null
  56. [ "$?" -eq 1 ] && brew install $dep
  57. done
  58. envpath="$programspath/env"
  59. [ ! -d "$envpath" ] && virtualenv $programspath/env
  60. source $envpath/bin/activate
  61. pip install -r $installerpath/requirements.txt
  62. else
  63. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  64. sudo apt-get install -y alsa-utils alsa-tools
  65. sudo apt-get install -y libudev-dev
  66. sudo apt-get install -y tmux
  67. sudo apt-get install -y vim
  68. sudo apt-get install -y autossh
  69. sudo apt-get install -y git-core
  70. sudo apt-get install -y build-essential
  71. sudo apt-get install -y nodejs
  72. sudo apt-get install -y python-dev
  73. sudo apt-get install -y lame
  74. sudo apt-get install -y ezstream
  75. sudo apt-get install -y cmake
  76. sudo apt-get install -y rtl-sdr
  77. sudo apt-get install -y sqlite3
  78. sudo apt-get install -y portaudio19-dev
  79. sudo pip install pyaudio
  80. sudo apt-get install -y ffmpeg
  81. sudo pip install pydub
  82. sudo pip install numpy
  83. sudo apt-get install -y gfortran libopenblas-dev liblapack-dev
  84. sudo pip install scipy
  85. sudo apt-get install -y python-matplotlib
  86. sudo apt-get install -y curl
  87. sudo pip install requests
  88. sudo pip install python-firebase
  89. cd tools
  90. sudo python ./setup.py install
  91. cd ..
  92. fi
  93. sudo chmod 0600 $installerpath/repokey
  94. cd $programspath
  95. clonerepo fourier-module.git module
  96. clonerepo fourier-common.git common
  97. clonerepo fourier-server.git server
  98. clonerepo fourier-fourier.git fourier
  99. clonerepo fourier-alt.git fourier-alt
  100. clonerepo fourier-monitor.git monitor
  101. clonerepo fourier-uploader.git uploader
  102. clonerepo fourier-ondemand.git ondemand
  103. cd $programspath/server
  104. npm install
  105. cd $programspath/monitor
  106. npm install
  107. cd $programspath/uploader
  108. npm install
  109. cd $programspath/module
  110. sudo python setup.py install
  111. cd $programspath/ondemand
  112. sudo python setup.py install
  113. sudo npm install -g pm2
  114. # build sdr lib
  115. if [[ "$OSTYPE" != darwin* ]]; then
  116. sudo apt-get install -y libusb-1.0-0-dev
  117. cd $programspath
  118. clonerepo rtl-sdr.git rtl-sdr
  119. cd $programspath/rtl-sdr
  120. mkdir build
  121. cd build
  122. cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
  123. make
  124. sudo cp ./src/rtl_fm /usr/bin/rtl_fm
  125. echo "SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", MODE:="0666"" | sudo tee -a /etc/udev/rules.d/rtl-sdr.rules
  126. fi
  127. # --------------------------------- #
  128. # Generación de los scripts con pm2 #
  129. # --------------------------------- #
  130. # cd $programspath
  131. # pm2 start fourier-ondemand --interpreter python --name ondemand
  132. # pm2 start server
  133. # pm2 start monitor
  134. # pm2 start uploader
  135. [ ! -f "$configfile" ] && \
  136. sudo python $installerpath/configure.py \
  137. $installerpath/fourier-config.json \
  138. $configfile \
  139. -programs "$programspath" \
  140. -receivers $RECEIVERS_COUNT \
  141. -api-secret $API_SECRET \
  142. -box-id "$BOX_ID"
  143. if [[ "$OSTYPE" != darwin* ]]; then
  144. sudo mysql -u root -e "create database $mysql_db;"
  145. sudo mysql -u root -e "create user '$mysql_user'@'localhost' identified by '$mysql_passwd';"
  146. sudo mysql -u root -e "grant all privileges on $mysql_db.* to '$mysql_user'@'localhost';flush privileges;"
  147. cd ~
  148. sudo mysql -u root -h localhost $mysql_db < $installerpath/fourier.sql
  149. sudo cp $installerpath/fourier-key.json /etc/Fourier-key.json
  150. fi
  151. findmnt $mount_point
  152. if [ "$?" -neq 0 ]; then
  153. echo -e '\e[34mData drive is not mounted\e[0m'
  154. fi
  155. echo "****************************************************************************"
  156. echo "REMEMBER: Initialize attached storage and create a symlink named $datapath pointing to the storage volume"
  157. echo "****************************************************************************"