選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

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