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

142 行
4.4 KiB

  1. #!/bin/bash -e
  2. on_chroot << EOF
  3. mkdir -p "/home/${FIRST_USER_NAME}/PiSDR/Software"
  4. cd "/home/${FIRST_USER_NAME}/PiSDR/Software"
  5. if [ ! -d "dump1090" ]; then
  6. mkdir -p "/home/${FIRST_USER_NAME}/PiSDR/Software/dump1090"
  7. fi
  8. install -v -o 1000 -g 1000 -m 755 targets/enable.sh "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/PiSDR/Software/dump1090"
  9. install -v -o 1000 -g 1000 -m 755 targets/disable.sh "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/PiSDR/Software/dump1090"
  10. install -v -o 1000 -g 1000 -m 755 targets/configure_rbfeeder.sh "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/PiSDR/Software/dump1090"
  11. install -v -o 1000 -g 1000 -m 755 targets/configure_fr24feed.sh "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/PiSDR/Software/dump1090"
  12. cd dump1090
  13. repository="https://github.com/wiedehopf/readsb.git"
  14. apt-get update
  15. apt-get install --no-install-recommends --no-install-suggests -y git build-essential debhelper libusb-1.0-0-dev \
  16. pkg-config dh-systemd libncurses5-dev lighttpd zlib1g-dev zlib1g unzip
  17. rm -rf "$ipath"/git
  18. if ! git clone --branch stale --depth 1 "$repository" "$ipath/git"
  19. then
  20. echo "Unable to git clone the repository"
  21. exit 1
  22. fi
  23. rm -rf "$ipath"/readsb*.deb
  24. cd "$ipath/git"
  25. sed -i 's/librtlsdr0, librtlsdr-dev, //g' debian/control
  26. export DEB_BUILD_OPTIONS=noddebs
  27. if ! dpkg-buildpackage -b -Prtlsdr -ui -uc -us
  28. then
  29. echo "Something went wrong building the debian package, exiting!"
  30. exit 1
  31. fi
  32. echo "Installing the Package"
  33. if ! dpkg -i ../readsb_*.deb
  34. then
  35. echo "Something went wrong installing the debian package, exiting!"
  36. exit 1
  37. fi
  38. echo "Package installed!"
  39. cp -n debian/lighttpd/* /etc/lighttpd/conf-available
  40. # script to change gain
  41. mkdir -p /usr/local/bin
  42. cat >/usr/local/bin/readsb-gain <<"EOF"
  43. #!/bin/bash
  44. gain=$(echo $1 | tr -cd '[:digit:].-')
  45. if [[ $gain == "" ]]; then echo "Error, invalid gain!"; exit 1; fi
  46. if ! grep gain /etc/default/readsb &>/dev/null; then sed -i -e 's/RECEIVER_OPTIONS="/RECEIVER_OPTIONS="--gain 49.6 /' /etc/default/readsb; fi
  47. sudo sed -i -E -e "s/--gain .?[0-9]*.?[0-9]* /--gain $gain /" /etc/default/readsb
  48. sudo systemctl restart readsb
  49. EOF
  50. chmod a+x /usr/local/bin/readsb-gain
  51. # set-location
  52. cat >/usr/local/bin/readsb-set-location <<"EOF"
  53. #!/bin/bash
  54. lat=$(echo $1 | tr -cd '[:digit:].-')
  55. lon=$(echo $2 | tr -cd '[:digit:].-')
  56. if ! awk "BEGIN{ exit ($lat > 90) }" || ! awk "BEGIN{ exit ($lat < -90) }"; then
  57. echo
  58. echo "Invalid latitude: $lat"
  59. echo "Latitude must be between -90 and 90"
  60. echo
  61. echo "Example format for latitude: 51.528308"
  62. echo
  63. echo "Usage:"
  64. echo "readsb-set-location 51.52830 -0.38178"
  65. echo
  66. exit 1
  67. fi
  68. if ! awk "BEGIN{ exit ($lon > 180) }" || ! awk "BEGIN{ exit ($lon < -180) }"; then
  69. echo
  70. echo "Invalid longitude: $lon"
  71. echo "Longitude must be between -180 and 180"
  72. echo
  73. echo "Example format for latitude: -0.38178"
  74. echo
  75. echo "Usage:"
  76. echo "readsb-set-location 51.52830 -0.38178"
  77. echo
  78. exit 1
  79. fi
  80. echo
  81. echo "setting Latitude: $lat"
  82. echo "setting Longitude: $lon"
  83. echo
  84. if ! grep -e '--lon' /etc/default/readsb &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lon -0.38178 /' /etc/default/readsb; fi
  85. if ! grep -e '--lat' /etc/default/readsb &>/dev/null; then sed -i -e 's/DECODER_OPTIONS="/DECODER_OPTIONS="--lat 51.52830 /' /etc/default/readsb; fi
  86. sed -i -E -e "s/--lat .?[0-9]*.?[0-9]* /--lat $lat /" /etc/default/readsb
  87. sed -i -E -e "s/--lon .?[0-9]*.?[0-9]* /--lon $lon /" /etc/default/readsb
  88. systemctl restart readsb
  89. EOF
  90. chmod a+x /usr/local/bin/readsb-set-location
  91. echo --------------
  92. cd "$ipath"
  93. wget -O tar1090-install.sh https://raw.githubusercontent.com/wiedehopf/tar1090/master/install.sh
  94. bash tar1090-install.sh /run/readsb
  95. if ! systemctl show readsb | grep 'ExecMainStatus=0' -qs; then
  96. echo --------------
  97. echo --------------
  98. journalctl -u readsb | tail -n30
  99. echo --------------
  100. echo --------------
  101. echo "ERROR: readsb service didn't start, if inquiring about the issue please post the above 30 lines of log!"
  102. echo " common issues: SDR not plugged in."
  103. echo " the webinterface will show an error until readsb is running!"
  104. echo --------------
  105. fi
  106. echo --------------
  107. echo "[PiSDR] Disabling services. To enable them, run 'bash enable.sh'."
  108. systemctl disable --now readsb
  109. systemctl disable --now tar1090
  110. systemctl disable --now lighttpd
  111. echo "[PiSDR] Deleting build files to save space."
  112. rm -fr /usr/local/share/tar1090/git-db
  113. rm -fr /usr/local/share/tar1090/git
  114. EOF