Não pode escolher mais do que 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 6.3 KiB

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