DIU-deploy-site-specific 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. SRV_LST=$BASEDIR/server_list
  36. SYNC_PORT=$BASEDIR/sync_port
  37. SYNC_SRV_DESC=$BASEDIR/sync_server_desc
  38. SYNC_TARGET=$BASEDIR/sync_target
  39. DRIVER_FN=$BASEDIR/drivers.txt
  40. EQUIP_FN=$BASEDIR/equipnum.txt
  41. RULE_FN=$BASEDIR/rules.scm
  42. DIU_UI=$BASEDIR/diu_ui_site_specific.js
  43. if [[ -e "$SSH_FILE" ]] ; then
  44. echo "# deploying SSH file $SSH_FILE to /home/bus/.ssh"
  45. cp -L -f "$SSH_FILE" /home/bus/.ssh/id_rsa
  46. chmod a-rwx /home/bus/.ssh/id_rsa
  47. chmod u+r /home/bus/.ssh/id_rsa
  48. else
  49. echo "# FILE NOT FOUND (SSH id_rsa): $SSH_FILE"
  50. fi
  51. if [[ -e "$COM_VAL" ]] ; then
  52. echo "# deploying common_values.sh file $COM_VAL to /home/bus/config/common_values.sh"
  53. cp -L -f "$COM_VAL" /home/bus/bin/common_values.sh
  54. else
  55. echo "# FILE NOT FOUND (COMMON VALUES): $COM_VAL"
  56. fi
  57. ###
  58. if [[ -e "$SRV_LST" ]] ; then
  59. echo "# deploying server list file: $SRV_LST -> /home/bus/config/server/server_list"
  60. cp -L -f "$SRV_LST" /home/bus/config/server/server_list
  61. else
  62. echo "# FILE NOT FOUND (SERVER LIST): $SRV_LST"
  63. fi
  64. if [[ -e "$SYNC_PORT" ]] ; then
  65. echo "# deploying sync port file: $SRV_PORT -> /home/bus/config/server/sync_port"
  66. cp -L -f "$SYNC_PORT" /home/bus/config/server/sync_port
  67. else
  68. echo "# FILE NOT FOUND (SYNC PORT): $SYNC_PORT"
  69. fi
  70. if [[ -e "$SYNC_SRV_DESC" ]] ; then
  71. echo "# deploying server list file: $SRV_SRV_DESC -> /home/bus/config/server/sync_server_desc"
  72. cp -L -f "$SYNC_SRV_DESC" /home/bus/config/server/sync_server_desc
  73. else
  74. echo "# FILE NOT FOUND (SYNC DESC): $SYNC_SRV_DESC"
  75. fi
  76. if [[ -e "$SYNC_TARGET" ]] ; then
  77. echo "# deploying server list file: $SRV_TARGET -> /home/bus/config/server/sync_target"
  78. cp -L -f "$SYNC_TARGET" /home/bus/config/server/sync_target
  79. else
  80. echo "# FILE NOT FOUND (SYNC TARGET): $SYNC_TARGET"
  81. fi
  82. ###
  83. if [[ -e "$DRIVER_FN" ]] ; then
  84. echo "# deploying drivers.txt file $DRIVER_FN to /home/bus/config/drivers.txt"
  85. cp -L -f "$DRIVER_FN" /home/bus/config/drivers.txt
  86. else
  87. echo "# FILE NOT FOUND (DRIVERS): $DRIVER_FN"
  88. fi
  89. if [[ -e "$EQUIP_FN" ]] ; then
  90. echo "# deploying equipnum.txt file $EQUIP_FN to /home/bus/config/equipnum.txt"
  91. cp -L -f "$EQUIP_FN" /home/bus/bin/equipnum.txt
  92. else
  93. echo "# FILE NOT FOUND (EQUIPNUM): $EQUIP_FN"
  94. fi
  95. if [[ -e "$RULE_FN" ]] ; then
  96. echo "# deploying rules.scm file $RULE_FN to /home/bus/config/rules.scm"
  97. cp -L -f "$RULE_FN" /home/bus/config/rules.scm
  98. else
  99. echo "# FILE NOT FOUND (RULES): $RULE_FN"
  100. fi
  101. ###
  102. if [[ -e "$DIU_UI" ]] ; then
  103. echo "# deploying diu_site_specific file: $DIU_UI -> /home/bus/config/html/js/diu_site_sepcific.js"
  104. cp -L -f "$DIU_UI" /home/bus/config/html/js/diu_site_specific.js
  105. else
  106. echo "# FILE NOT FOUND (DIU SITE SPECIFIC): $DIU_UI"
  107. fi
  108. for pfn in `find data -name '*.paddle' -type f` ; do
  109. bpfn=`basename $pfn`
  110. echo "# deploying paddle file: $pfn -> /home/bus/config/$bpfn"
  111. cp -L -f "$pfn" /home/bus/config/$bpfn
  112. done
  113. echo "# done"