Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

237 wiersze
6.2 KiB

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