DIU-deploy-site-specific 4.2 KB

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