Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

135 rindas
4.2 KiB

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