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.

pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 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 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 "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 "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 "wxtoimgrc" "$HOME/.wxtoimgrc"
  101. log_done "$HOME/.wxtoimgrc installed"
  102. fi
  103. ### Install meteor_demod
  104. if [ -e /usr/bin/meteor_demod ]; then
  105. log_done "meteor_demod was already installed"
  106. else
  107. log_running "Installing meteor_demod..."
  108. (
  109. cd /tmp
  110. git clone https://github.com/dbdexter-dev/meteor_demod.git
  111. cd meteor_demod
  112. make
  113. sudo make install
  114. )
  115. log_done "meteor_demod installed"
  116. fi
  117. ### Install medet_arm
  118. if [ -e /usr/bin/medet_arm ]; then
  119. log_done "medet_arm was already installed"
  120. else
  121. log_running "Installing medet_arm..."
  122. sudo cp medet_arm /usr/bin/medet_arm
  123. sudo chmod +x /usr/bin/medet_arm
  124. log_done "medet_arm installed"
  125. fi
  126. ### Cron the scheduler
  127. crontab -l | grep -q "raspberry-noaa"
  128. if [ $? -eq 0 ]; then
  129. log_done "Crontab for schedule.sh already exists"
  130. else
  131. cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab -
  132. log_done "Crontab installed"
  133. fi
  134. ### Setup Nginx
  135. log_running "Setting up Nginx..."
  136. sudo cp nginx.cfg /etc/nginx/sites-enabled/default
  137. (
  138. sudo mkdir -p /var/www/wx
  139. sudo chown -R www-data:www-data /var/www/wx
  140. sudo usermod -a -G www-data pi
  141. sudo chmod 775 /var/www/wx
  142. )
  143. sudo systemctl restart nginx
  144. if [ ! -e /var/www/wx/index.html ]; then
  145. cp index.html /var/www/wx/index.html
  146. fi
  147. log_done "Nginx configured"
  148. ### Setup ramFS
  149. cat /etc/fstab | grep -q "ramfs"
  150. if [ $? -eq 0 ]; then
  151. log_done "ramfs already setup"
  152. else
  153. sudo mkdir -p /var/ramfs
  154. cat fstab | sudo tee -a /etc/fstab > /dev/null
  155. log_done "Ramfs installed"
  156. fi
  157. set +e
  158. sudo mount -a
  159. set -e
  160. sudo chmod 777 /var/ramfs
  161. success "Install (almost) done! Let's do some configuration"
  162. echo "
  163. It's time to configure your ground station
  164. You'll be asked for your latitude and longitude
  165. Use negative values for South and West
  166. "
  167. read -rp "Enter your latitude (South values are negative): "
  168. lat=$REPLY
  169. read -rp "Enter your longitude (West values are negative): "
  170. lon=$REPLY
  171. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.noaa.conf"
  172. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoimgrc"
  173. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth"
  174. sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "sun.py"
  175. success "Install done! Double check your $HOME/.noaa.conf settings"