fourier_install.sh 5.8 KB

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