You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. nginx \
  39. libncurses5-dev \
  40. libncursesw5-dev \
  41. libatlas-base-dev \
  42. python3-pip \
  43. imagemagick \
  44. libxft-dev \
  45. libxft2
  46. sudo pip3 install numpy ephem tweepy Pillow
  47. log_done "Packages installed"
  48. ### Blacklist DVB modules
  49. if [ -e /etc/modprobe.d/rtlsdr.conf ]; then
  50. log_done "DVB modules were already blacklisted"
  51. else
  52. sudo cp modprobe.d/rtlsdr.conf /etc/modprobe.d/rtlsdr.conf
  53. log_done "DVB modules are blacklisted now"
  54. fi
  55. ### Install RTL-SDR
  56. if [ -e /usr/local/bin/rtl_fm ]; then
  57. log_done "rtl-sdr was already installed"
  58. else
  59. log_running "Installing rtl-sdr from osmocom..."
  60. (
  61. cd /tmp/
  62. git clone https://github.com/osmocom/rtl-sdr.git
  63. cd rtl-sdr/
  64. mkdir build
  65. cd build
  66. cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
  67. make
  68. sudo make install
  69. sudo ldconfig
  70. cd /tmp/
  71. sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
  72. )
  73. log_done "rtl-sdr install done"
  74. fi
  75. ### Install WxToIMG
  76. if [ -e /usr/local/bin/xwxtoimg ]; then
  77. log_done "WxToIMG was already installed"
  78. else
  79. log_running "Installing WxToIMG..."
  80. sudo dpkg -i wxtoimg-armhf-2.11.2-beta.deb
  81. log_done "WxToIMG installed"
  82. fi
  83. ### Install default config file
  84. if [ -e "$HOME/.noaa.conf" ]; then
  85. log_done "$HOME/.noaa.conf already exists"
  86. else
  87. cp ".noaa.conf" "$HOME/.noaa.conf"
  88. log_done "$HOME/.noaa.conf installed"
  89. fi
  90. if [ -e "$HOME/.predict/predict.qth" ]; then
  91. log_done "$HOME/.predict/predict.qth already exists"
  92. else
  93. cp "predict.qth" "$HOME/.predict/predict.qth"
  94. log_done "$HOME/.predict/predict.qth installed"
  95. fi
  96. ### Install meteor_demod
  97. if [ -e /usr/bin/meteor_demod ]; then
  98. log_done "meteor_demod was already installed"
  99. else
  100. log_running "Installing meteor_demod..."
  101. (
  102. cd /tmp
  103. git clone https://github.com/dbdexter-dev/meteor_demod.git
  104. cd meteor_demod
  105. make
  106. sudo make install
  107. )
  108. log_done "meteor_demod installed"
  109. fi
  110. ### Install medet_arm
  111. if [ -e /usr/bin/medet_arm ]; then
  112. log_done "medet_arm was already installed"
  113. else
  114. log_running "Installing medet_arm..."
  115. sudo cp medet_arm /usr/bin/medet_arm
  116. sudo chmod +x /usr/bin/medet_arm
  117. log_done "medet_arm installed"
  118. fi
  119. ### Cron the scheduler
  120. crontab -l | grep -q "raspberry-noaa"
  121. if [ $? -eq 0 ]; then
  122. log_done "Crontab for schedule.sh already exists"
  123. else
  124. cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab -
  125. log_done "Crontab installed"
  126. fi
  127. ### Setup Nginx
  128. log_running "Setting up Nginx..."
  129. sudo cp nginx.cfg /etc/nginx/sites-enabled/default
  130. (
  131. sudo mkdir -p /var/www/wx
  132. sudo chown -R www-data:www-data /var/www/wx
  133. sudo usermod -a -G www-data pi
  134. sudo chmod 775 /var/www/wx
  135. )
  136. sudo systemctl restart nginx
  137. if [ ! -e /var/www/wx/index.html ]; then
  138. cp index.html /var/www/wx/index.html
  139. fi
  140. log_done "Nginx configured"
  141. ### Setup ramFS
  142. cat /etc/fstab | grep -q "ramfs"
  143. if [ $? -eq 0 ]; then
  144. log_done "ramfs already setup"
  145. else
  146. sudo mkdir -p /var/ramfs
  147. cat fstab | sudo tee -a /etc/fstab > /dev/null
  148. log_done "Ramfs installed"
  149. fi
  150. set +e
  151. sudo mount -a
  152. set -e
  153. sudo chmod 777 /var/ramfs
  154. success "Install (almost) done! Let's do some configuration"
  155. echo "
  156. 1. Edit $HOME/.noaa.conf
  157. 2. Edit $HOME/.predict/predict.qth and set lat/lon data
  158. 3. Edit sun.py and set lat/lon data
  159. "