fourier_install.sh 5.3 KB

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