Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

install.sh 4.1 KiB

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