Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

install.sh 5.9 KiB

4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. sudo pip3 install numpy ephem tweepy Pillow
  50. log_done "Packages installed"
  51. ### Blacklist DVB modules
  52. if [ -e /etc/modprobe.d/rtlsdr.conf ]; then
  53. log_done "DVB modules were already blacklisted"
  54. else
  55. sudo cp templates/modprobe.d/rtlsdr.conf /etc/modprobe.d/rtlsdr.conf
  56. log_done "DVB modules are blacklisted now"
  57. fi
  58. ### Install RTL-SDR
  59. if [ -e /usr/local/bin/rtl_fm ]; then
  60. log_done "rtl-sdr was already installed"
  61. else
  62. log_running "Installing rtl-sdr from osmocom..."
  63. (
  64. cd /tmp/
  65. git clone https://github.com/osmocom/rtl-sdr.git
  66. cd rtl-sdr/
  67. mkdir build
  68. cd build
  69. cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
  70. make
  71. sudo make install
  72. sudo ldconfig
  73. cd /tmp/
  74. sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
  75. )
  76. log_done "rtl-sdr install done"
  77. fi
  78. ### Install WxToIMG
  79. if [ -e /usr/local/bin/xwxtoimg ]; then
  80. log_done "WxToIMG was already installed"
  81. else
  82. log_running "Installing WxToIMG..."
  83. sudo dpkg -i software/wxtoimg-armhf-2.11.2-beta.deb
  84. log_done "WxToIMG installed"
  85. fi
  86. ### Install default config file
  87. if [ -e "$HOME/.noaa.conf" ]; then
  88. log_done "$HOME/.noaa.conf already exists"
  89. else
  90. cp "templates/noaa.conf" "$HOME/.noaa.conf"
  91. log_done "$HOME/.noaa.conf installed"
  92. fi
  93. if [ -d "$HOME/.predict" ] && [ -e "$HOME/.predict/predict.qth" ]; then
  94. log_done "$HOME/.predict/predict.qth already exists"
  95. else
  96. mkdir "$HOME/.predict"
  97. cp "templates/predict.qth" "$HOME/.predict/predict.qth"
  98. log_done "$HOME/.predict/predict.qth installed"
  99. fi
  100. if [ -e "$HOME/.wxtoimgrc" ]; then
  101. log_done "$HOME/.wxtoimgrc already exists"
  102. else
  103. cp "templates/wxtoimgrc" "$HOME/.wxtoimgrc"
  104. log_done "$HOME/.wxtoimgrc installed"
  105. fi
  106. if [ -e "$HOME/.tweepy.conf" ]; then
  107. log_done "$HOME/.tweepy.conf already exists"
  108. else
  109. cp "templates/tweepy.conf" "$HOME/.tweepy.conf"
  110. log_done "$HOME/.tweepy.conf installed"
  111. fi
  112. ### Install meteor_demod
  113. if [ -e /usr/bin/meteor_demod ]; then
  114. log_done "meteor_demod was already installed"
  115. else
  116. log_running "Installing meteor_demod..."
  117. (
  118. cd /tmp
  119. git clone https://github.com/dbdexter-dev/meteor_demod.git
  120. cd meteor_demod
  121. make
  122. sudo make install
  123. )
  124. log_done "meteor_demod installed"
  125. fi
  126. ### Install medet_arm
  127. if [ -e /usr/bin/medet_arm ]; then
  128. log_done "medet_arm was already installed"
  129. else
  130. log_running "Installing medet_arm..."
  131. sudo cp software/medet_arm /usr/bin/medet_arm
  132. sudo chmod +x /usr/bin/medet_arm
  133. log_done "medet_arm installed"
  134. fi
  135. ### Cron the scheduler
  136. set +e
  137. crontab -l | grep -q "raspberry-noaa"
  138. if [ $? -eq 0 ]; then
  139. log_done "Crontab for schedule.sh already exists"
  140. else
  141. cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab -
  142. log_done "Crontab installed"
  143. fi
  144. set -e
  145. ### Setup Nginx
  146. log_running "Setting up Nginx..."
  147. sudo cp templates/nginx.cfg /etc/nginx/sites-enabled/default
  148. (
  149. sudo mkdir -p /var/www/wx
  150. sudo chown -R www-data:www-data /var/www/wx
  151. sudo usermod -a -G www-data pi
  152. sudo chmod 775 /var/www/wx
  153. )
  154. sudo systemctl restart nginx
  155. if [ ! -e /var/www/wx/index.html ]; then
  156. cp templates/index.html /var/www/wx/index.html
  157. fi
  158. if [ ! -e /var/www/wx/logo-small.png ]; then
  159. cp templates/logo-small.png /var/www/wx/logo-small.png
  160. fi
  161. log_done "Nginx configured"
  162. ### Setup ramFS
  163. cat /etc/fstab | grep -q "ramfs"
  164. if [ $? -eq 0 ]; then
  165. log_done "ramfs already setup"
  166. else
  167. sudo mkdir -p /var/ramfs
  168. cat templates/fstab | sudo tee -a /etc/fstab > /dev/null
  169. log_done "Ramfs installed"
  170. fi
  171. set +e
  172. sudo mount -a
  173. set -e
  174. sudo chmod 777 /var/ramfs
  175. success "Install (almost) done!"
  176. echo "
  177. It's time to configure your ground station
  178. You'll be asked for your latitude and longitude
  179. Use negative values for South and West
  180. "
  181. read -rp "Enter your latitude (South values are negative): "
  182. lat=$REPLY
  183. read -rp "Enter your longitude (West values are negative): "
  184. lon=$REPLY
  185. read -rp "Enter your timezone (Ex: -3 for Argentina time): "
  186. timezone=$REPLY
  187. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.noaa.conf"
  188. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoimgrc"
  189. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth"
  190. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$timezone * -1" | bc)/g" "sun.py"
  191. # Running WXTOIMG to have the user accept the licensing agreement
  192. wxtoimg
  193. success "Install done! Double check your $HOME/.noaa.conf settings"
  194. echo "
  195. If you want to post your images to Twitter, please setup
  196. your Twitter credentials on $HOME/.tweepy.conf
  197. "