apply_update_legacy.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  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 /home/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. echo "$local_checksum" > /home/bus/config/$update_file.checksum
  41. echo "$file_version" > /home/bus/config/$update_file.version
  42. tar -zxf $update_file
  43. if [[ ! -d ./mnt/data2/config ]] ; then
  44. echo "Legacy update did not find 'mnt/data2/config', not going further"
  45. exit 0
  46. fi
  47. # We are specifically only interested in:
  48. # - *.paddle
  49. # - avls_freq.txt
  50. # - drivers.txt
  51. # - init.scm
  52. # - rules.scm
  53. # - rfid_patterns.txt
  54. #
  55. # only look for those files and deposit them in the appropriate place
  56. #
  57. find ./mnt/data2/config -name '*.paddle' -type f | \
  58. xargs -n1 -I{} cp -f {} /home/bus/config
  59. if [[ -e ./mnt/data2/config/avls_freq.txt ]] ; then
  60. cp -f ./mnt/data2/config/avls_freq.txt /home/bus/config/avls_freq.txt
  61. fi
  62. if [[ -e ./mnt/data2/config/drivers.txt ]] ; then
  63. cp -f ./mnt/data2/config/drivers.txt /home/bus/config/drivers.txt
  64. fi
  65. if [[ -e ./mnt/data2/config/init.scm ]] ; then
  66. cp -f ./mnt/data2/config/init.scm /home/bus/config/init.scm
  67. fi
  68. if [[ -e ./mnt/data2/config/rules.scm ]] ; then
  69. cp -f ./mnt/data2/config/rules.scm /home/bus/config/rules.scm
  70. fi
  71. if [[ -e ./mnt/data2/config/rfid_patterns.txt ]] ; then
  72. cp -f ./mnt/data2/config/rfid_patterns.txt /home/bus/config/rfid_patterns.txt
  73. fi
  74. exit 0
  75. fi
  76. exit 1