DIU-deploy-site-specific 4.0 KB

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