fourier_install.sh 5.8 KB

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