Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

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