DIU-deploy-site-specific 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2020 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. # This script is meant to be run from a USB stick, say, to deploy
  21. # this site specific files on a DIU.
  22. #
  23. # This includes
  24. #
  25. # * The private SSH key
  26. # * The `common_values.sh` file
  27. # * The `diu_ui_site_specific.js` admin interface file
  28. # * Any paddles that might need transfer
  29. #
  30. # This will look for a local `data` directory with all the appropriate files
  31. #
  32. BASEDIR="data"
  33. SSH_FILE=$BASEDIR/id_rsa
  34. COM_VAL=$BASEDIR/common_values.sh
  35. DIU_UI=$BASEDIR/diu_ui_site_specific.js
  36. if [[ -e "$SSH_FILE" ]] ; then
  37. echo "# deploying SSH file $SSH_FILE to /home/bus/.ssh"
  38. cp -L -f "$SSH_FILE" /home/bus/.ssh/id_rsa
  39. chmod a-rwx /home/bus/.ssh/id_rsa
  40. chmod u+r /home/bus/.ssh/id_rsa
  41. else
  42. echo "# FILE NOT FOUND (SSH id_rsa): $SSH_FILE"
  43. fi
  44. if [[ -e "$COM_VAL" ]] ; then
  45. echo "# deploying common_values.sh file $COM_VAL to /home/bus/config/common_values.sh"
  46. cp -L -f "$COM_VAL" /home/bus/config
  47. else
  48. echo "# FILE NOT FOUND (COMMON VALUES): $COM_VAL"
  49. fi
  50. if [[ -e "$DIU_UI" ]] ; then
  51. echo "# deploying diu_site_specific file: $DIU_UI -> /home/bus/config/html/js/diu_site_sepcific.js"
  52. cp -L -f "$DIU_UI" /home/bus/config/html/js/diu_site_specific.js
  53. else
  54. echo "# FILE NOT FOUND (DIU SITE SPECIFIC): $DIU_UI"
  55. fi
  56. for pfn in `find data -name '*.paddle' -type f` ; do
  57. bpfn=`basename $pfn`
  58. echo "# deploying paddle file: $pfn -> /home/bus/config/$bpfn"
  59. cp -L -f "$pfn" /home/bus/config/$bpfn
  60. done
  61. echo "# done"