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