Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

install.sh 6.3 KiB

il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. #!/bin/bash
  2. set -e
  3. RED=$(tput setaf 1)
  4. GREEN=$(tput setaf 2)
  5. YELLOW=$(tput setaf 3)
  6. BLUE=$(tput setaf 4)
  7. BOLD=$(tput bold)
  8. RESET=$(tput sgr0)
  9. die() {
  10. >&2 echo "${RED}error: $1${RESET}" && exit 1
  11. }
  12. log() {
  13. echo "$*"
  14. }
  15. log_done() {
  16. echo " ${GREEN}✓${RESET} $1"
  17. }
  18. log_running() {
  19. echo " ${YELLOW}*${RESET} $1"
  20. }
  21. success() {
  22. echo "${GREEN}$1${RESET}"
  23. }
  24. ### Verify cloned repo
  25. if [ ! -e "$HOME/raspberry-noaa" ]; then
  26. die "Is https://github.com/reynico/raspberry-noaa cloned in your home directory?"
  27. fi
  28. ### Install required packages
  29. log_running "Installing required packages..."
  30. sudo apt update -yq
  31. sudo apt install -yq predict \
  32. python-setuptools \
  33. ntp \
  34. cmake \
  35. libusb-1.0 \
  36. sox \
  37. at \
  38. bc \
  39. nginx \
  40. libncurses5-dev \
  41. libncursesw5-dev \
  42. libatlas-base-dev \
  43. python3-pip \
  44. imagemagick \
  45. libxft-dev \
  46. libxft2 \
  47. libjpeg9 \
  48. libjpeg9-dev \
  49. socat \
  50. php7.2-fpm \
  51. php7.2-sqlite \
  52. sqlite3
  53. sudo pip3 install numpy ephem tweepy Pillow
  54. log_done "Packages installed"
  55. ### Blacklist DVB modules
  56. if [ -e /etc/modprobe.d/rtlsdr.conf ]; then
  57. log_done "DVB modules were already blacklisted"
  58. else
  59. sudo cp templates/modprobe.d/rtlsdr.conf /etc/modprobe.d/rtlsdr.conf
  60. log_done "DVB modules are blacklisted now"
  61. fi
  62. ### Install RTL-SDR
  63. if [ -e /usr/local/bin/rtl_fm ]; then
  64. log_done "rtl-sdr was already installed"
  65. else
  66. log_running "Installing rtl-sdr from osmocom..."
  67. (
  68. cd /tmp/
  69. git clone https://github.com/osmocom/rtl-sdr.git
  70. cd rtl-sdr/
  71. mkdir build
  72. cd build
  73. cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
  74. make
  75. sudo make install
  76. sudo ldconfig
  77. cd /tmp/
  78. sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
  79. )
  80. log_done "rtl-sdr install done"
  81. fi
  82. ### Install WxToIMG
  83. if [ -e /usr/local/bin/xwxtoimg ]; then
  84. log_done "WxToIMG was already installed"
  85. else
  86. log_running "Installing WxToIMG..."
  87. sudo dpkg -i software/wxtoimg-armhf-2.11.2-beta.deb
  88. log_done "WxToIMG installed"
  89. fi
  90. ### Install default config file
  91. if [ -e "$HOME/.noaa.conf" ]; then
  92. log_done "$HOME/.noaa.conf already exists"
  93. else
  94. cp "templates/noaa.conf" "$HOME/.noaa.conf"
  95. log_done "$HOME/.noaa.conf installed"
  96. fi
  97. if [ -d "$HOME/.predict" ] && [ -e "$HOME/.predict/predict.qth" ]; then
  98. log_done "$HOME/.predict/predict.qth already exists"
  99. else
  100. mkdir "$HOME/.predict"
  101. cp "templates/predict.qth" "$HOME/.predict/predict.qth"
  102. log_done "$HOME/.predict/predict.qth installed"
  103. fi
  104. if [ -e "$HOME/.wxtoimgrc" ]; then
  105. log_done "$HOME/.wxtoimgrc already exists"
  106. else
  107. cp "templates/wxtoimgrc" "$HOME/.wxtoimgrc"
  108. log_done "$HOME/.wxtoimgrc installed"
  109. fi
  110. if [ -e "$HOME/.tweepy.conf" ]; then
  111. log_done "$HOME/.tweepy.conf already exists"
  112. else
  113. cp "templates/tweepy.conf" "$HOME/.tweepy.conf"
  114. log_done "$HOME/.tweepy.conf installed"
  115. fi
  116. ### Install meteor_demod
  117. if [ -e /usr/bin/meteor_demod ]; then
  118. log_done "meteor_demod was already installed"
  119. else
  120. log_running "Installing meteor_demod..."
  121. (
  122. cd /tmp
  123. git clone https://github.com/dbdexter-dev/meteor_demod.git
  124. cd meteor_demod
  125. make
  126. sudo make install
  127. )
  128. log_done "meteor_demod installed"
  129. fi
  130. ### Install medet_arm
  131. if [ -e /usr/bin/medet_arm ]; then
  132. log_done "medet_arm was already installed"
  133. else
  134. log_running "Installing medet_arm..."
  135. sudo cp software/medet_arm /usr/bin/medet_arm
  136. sudo chmod +x /usr/bin/medet_arm
  137. log_done "medet_arm installed"
  138. fi
  139. ### Cron the scheduler
  140. set +e
  141. crontab -l | grep -q "raspberry-noaa"
  142. if [ $? -eq 0 ]; then
  143. log_done "Crontab for schedule.sh already exists"
  144. else
  145. cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab -
  146. log_done "Crontab installed"
  147. fi
  148. set -e
  149. ### Setup Nginx
  150. log_running "Setting up Nginx..."
  151. sudo cp templates/nginx.cfg /etc/nginx/sites-enabled/default
  152. (
  153. sudo mkdir -p /var/www/wx
  154. sudo chown -R www-data:www-data /var/www/wx
  155. sudo usermod -a -G www-data pi
  156. sudo chmod 775 /var/www/wx
  157. )
  158. sudo systemctl restart nginx
  159. if [ ! -e /var/www/wx/index.html ]; then
  160. sudo cp templates/index.html /var/www/wx/index.html
  161. fi
  162. if [ ! -e /var/www/wx/logo-small.png ]; then
  163. sudo cp templates/logo-small.png /var/www/wx/logo-small.png
  164. fi
  165. log_done "Nginx configured"
  166. ### Setup ramFS
  167. set +e
  168. cat /etc/fstab | grep -q "ramfs"
  169. if [ $? -eq 0 ]; then
  170. log_done "ramfs already setup"
  171. else
  172. sudo mkdir -p /var/ramfs
  173. cat templates/fstab | sudo tee -a /etc/fstab > /dev/null
  174. log_done "Ramfs installed"
  175. fi
  176. sudo mount -a
  177. sudo chmod 777 /var/ramfs
  178. set -e
  179. success "Install (almost) done!"
  180. read -rp "Do you want to enable bias-tee? (y/N)"
  181. if [[ $REPLY =~ ^[Yy]$ ]]; then
  182. sed -i -e "s/enable_bias_tee/-T/g" "$HOME/.noaa.conf"
  183. log_done "Bias-tee is enabled!"
  184. else
  185. sed -i -e "s/enable_bias_tee//g" "$HOME/.noaa.conf"
  186. fi
  187. echo "
  188. It's time to configure your ground station
  189. You'll be asked for your latitude and longitude
  190. Use negative values for South and West
  191. "
  192. read -rp "Enter your latitude (South values are negative): "
  193. lat=$REPLY
  194. read -rp "Enter your longitude (West values are negative): "
  195. lon=$REPLY
  196. read -rp "Enter your timezone (Ex: -3 for Argentina time): "
  197. timezone=$REPLY
  198. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.noaa.conf"
  199. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoimgrc"
  200. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth"
  201. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$timezone * -1" | bc)/g" "sun.py"
  202. # Running WXTOIMG to have the user accept the licensing agreement
  203. wxtoimg
  204. success "Install done! Double check your $HOME/.noaa.conf settings"
  205. echo "
  206. If you want to post your images to Twitter, please setup
  207. your Twitter credentials on $HOME/.tweepy.conf
  208. "