| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/bin/bash
- #
- # Copyright (c) 2020 Clementine Computing LLC.
- #
- # This file is part of PopuFare.
- #
- # PopuFare is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # PopuFare is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
- #
- # This script is meant to be run from a USB stick, say, to deploy
- # this site specific files on a DIU.
- #
- # This includes
- #
- # * The private SSH key
- # * The `common_values.sh` file
- # * The `diu_ui_site_specific.js` admin interface file
- # * Any paddles that might need transfer
- #
- # This will look for a local `data` directory with all the appropriate files
- #
- BASEDIR="data"
- SSH_FILE=$BASEDIR/id_rsa_bus
- COM_VAL=$BASEDIR/common_values.sh
- SRV_LST=$BASEDIR/server_list
- SYNC_PORT=$BASEDIR/sync_port
- SYNC_SRV_DESC=$BASEDIR/sync_server_desc
- SYNC_TARGET=$BASEDIR/sync_target
- DRIVER_FN=$BASEDIR/drivers.txt
- EQUIP_FN=$BASEDIR/equipnum.txt
- RULE_FN=$BASEDIR/rules.scm
- DIU_UI=$BASEDIR/diu_ui_site_specific.js
- if [[ -e "$SSH_FILE" ]] ; then
- echo "# deploying SSH file $SSH_FILE to /home/bus/.ssh"
- cp -L -f "$SSH_FILE" /home/bus/.ssh/id_rsa_bus
- chown bus:bus /home/bus/.ssh/id_rsa_bus
- chmod a-rwx /home/bus/.ssh/id_rsa_bus
- chmod u+r /home/bus/.ssh/id_rsa_bus
- else
- echo "# FILE NOT FOUND (SSH id_rsa): $SSH_FILE"
- fi
- if [[ -e "$COM_VAL" ]] ; then
- echo "# deploying common_values.sh file $COM_VAL to /home/bus/config/common_values.sh"
- cp -L -f "$COM_VAL" /home/bus/bin/common_values.sh
- else
- echo "# FILE NOT FOUND (COMMON VALUES): $COM_VAL"
- fi
- ###
- if [[ -e "$SRV_LST" ]] ; then
- echo "# deploying server list file: $SRV_LST -> /home/bus/config/server/server_list"
- cp -L -f "$SRV_LST" /home/bus/config/server/server_list
- else
- echo "# FILE NOT FOUND (SERVER LIST): $SRV_LST"
- fi
- if [[ -e "$SYNC_PORT" ]] ; then
- echo "# deploying sync port file: $SRV_PORT -> /home/bus/config/server/sync_port"
- cp -L -f "$SYNC_PORT" /home/bus/config/server/sync_port
- else
- echo "# FILE NOT FOUND (SYNC PORT): $SYNC_PORT"
- fi
- if [[ -e "$SYNC_SRV_DESC" ]] ; then
- echo "# deploying server list file: $SRV_SRV_DESC -> /home/bus/config/server/sync_server_desc"
- cp -L -f "$SYNC_SRV_DESC" /home/bus/config/server/sync_server_desc
- else
- echo "# FILE NOT FOUND (SYNC DESC): $SYNC_SRV_DESC"
- fi
- if [[ -e "$SYNC_TARGET" ]] ; then
- echo "# deploying server list file: $SRV_TARGET -> /home/bus/config/server/sync_target"
- cp -L -f "$SYNC_TARGET" /home/bus/config/server/sync_target
- else
- echo "# FILE NOT FOUND (SYNC TARGET): $SYNC_TARGET"
- fi
- ###
- if [[ -e "$DRIVER_FN" ]] ; then
- echo "# deploying drivers.txt file $DRIVER_FN to /home/bus/config/drivers.txt"
- cp -L -f "$DRIVER_FN" /home/bus/config/drivers.txt
- else
- echo "# FILE NOT FOUND (DRIVERS): $DRIVER_FN"
- fi
- if [[ -e "$EQUIP_FN" ]] ; then
- echo "# deploying equipnum.txt file $EQUIP_FN to /home/bus/config/equipnum.txt"
- cp -L -f "$EQUIP_FN" /home/bus/bin/equipnum.txt
- else
- echo "# FILE NOT FOUND (EQUIPNUM): $EQUIP_FN"
- fi
- if [[ -e "$RULE_FN" ]] ; then
- echo "# deploying rules.scm file $RULE_FN to /home/bus/config/rules.scm"
- cp -L -f "$RULE_FN" /home/bus/config/rules.scm
- else
- echo "# FILE NOT FOUND (RULES): $RULE_FN"
- fi
- ###
- if [[ -e "$DIU_UI" ]] ; then
- echo "# deploying diu_site_specific file: $DIU_UI -> /home/bus/config/html/js/diu_site_sepcific.js"
- cp -L -f "$DIU_UI" /home/bus/config/html/js/diu_site_specific.js
- else
- echo "# FILE NOT FOUND (DIU SITE SPECIFIC): $DIU_UI"
- fi
- for pfn in `find data -name '*.paddle' -type f` ; do
- bpfn=`basename $pfn`
- echo "# deploying paddle file: $pfn -> /home/bus/config/$bpfn"
- cp -L -f "$pfn" /home/bus/config/$bpfn
- done
- echo "# done"
|