fourier_install.sh 5.7 KB

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