apply_update_legacy.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2019 Clementine Computing LLC.
  4. #
  5. # This file is part of PopuFare.
  6. #
  7. # PopuFare is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # PopuFare is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  19. #
  20. update_file="$1"
  21. update_checksum="$2"
  22. file_size="$3"
  23. server_path="$4"
  24. file_version="$5"
  25. . /home/bus/bin/common_values.sh
  26. # Confirm we have a checksum that differs from our existing checksum
  27. #
  28. if [[ -f /home/bus/config/$update_file.checksum ]] ; then
  29. existing_checksum=`cat /hom/bus/config/$update_file.checksum`
  30. if [[ "$update_checksum" == "$existing_checksum" ]] ; then
  31. echo "We already HAVE an update $update_file with checksum $update_checksum, aborting install"
  32. exit 1
  33. fi
  34. fi
  35. local_checksum=`md5sum $update_file | cut -d' ' -f1`
  36. # We are doing a 'legacy' install, so unpack the package locally and only
  37. # check for appropriate files in the 'config' directory.
  38. #
  39. if [[ "$update_checksum" == "$local_checksum" ]] ; then
  40. tar -zxf $update_file
  41. if [[ ! -d ./mnt/data2/config ]] ; then
  42. echo "Legacy update did not find 'mnt/data2/config', not going further"
  43. exit 0
  44. fi
  45. # We are specifically only interested in:
  46. # - *.paddle
  47. # - avls_freq.txt
  48. # - drivers.txt
  49. # - init.scm
  50. # - rules.scm
  51. # - rfid_patterns.txt
  52. #
  53. # only look for those files and deposit them in the appropriate place
  54. #
  55. find ./mnt/data2/config -name '*.paddle' -type f | \
  56. xargs -n1 -I{} cp -f {} /home/bus/config
  57. if [[ -e ./mnt/data2/config/avls_freq.txt ]] ; then
  58. cp -f ./mnt/data2/config/avls_freq.txt /home/bus/config/avls_freq.txt
  59. fi
  60. if [[ -e ./mnt/data2/config/drivers.txt ]] ; then
  61. cp -f ./mnt/data2/config/drivers.txt /home/bus/config/drivers.txt
  62. fi
  63. if [[ -e ./mnt/data2/config/init.scm ]] ; then
  64. cp -f ./mnt/data2/config/init.scm /home/bus/config/init.scm
  65. fi
  66. if [[ -e ./mnt/data2/config/rules.scm ]] ; then
  67. cp -f ./mnt/data2/config/rules.scm /home/bus/config/rules.scm
  68. fi
  69. if [[ -e ./mnt/data2/config/rfid_patterns.txt ]] ; then
  70. cp -f ./mnt/data2/config/rfid_patterns.txt /home/bus/config/rfid_patterns.txt
  71. fi
  72. exit 0
  73. fi
  74. exit 1