michael@0: #!/bin/bash michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: # michael@0: # This script expects the following environment variables to be set: michael@0: # SYMBOL_SERVER_HOST : host to upload symbols to michael@0: # SYMBOL_SERVER_USER : username on that host michael@0: # SYMBOL_SERVER_PATH : path on that host to put symbols in michael@0: # michael@0: # And will use the following optional environment variables if set: michael@0: # SYMBOL_SERVER_SSH_KEY : path to a ssh private key to use michael@0: # SYMBOL_SERVER_PORT : port to use for ssh michael@0: # POST_SYMBOL_UPLOAD_CMD: a commandline to run on the remote host after michael@0: # uploading. The full path of the symbol index michael@0: # file will be appended to the commandline. michael@0: # michael@0: # The script expects two command-line arguments, in this order: michael@0: # - The symbol index name michael@0: # - The symbol archive michael@0: # michael@0: michael@0: set -e michael@0: michael@0: : ${SYMBOL_SERVER_HOST?} ${SYMBOL_SERVER_USER?} ${SYMBOL_SERVER_PATH?} ${1?"You must specify a symbol index name."} ${2?"You must specify a symbol archive to upload"} michael@0: michael@0: SYMBOL_INDEX_NAME="$1" michael@0: SYMBOL_ARCHIVE="$2" michael@0: michael@0: hash=`openssl dgst -sha1 "${SYMBOL_ARCHIVE}" | sed 's/^.*)=//' | sed 's/\ //g'` michael@0: archive="${hash}-"`basename "${SYMBOL_ARCHIVE}" | sed 's/\ //g'` michael@0: echo "Transferring symbols... ${SYMBOL_ARCHIVE}" michael@0: scp -oLogLevel=DEBUG -oRekeyLimit=10M ${SYMBOL_SERVER_PORT:+-P $SYMBOL_SERVER_PORT} \ michael@0: ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} "${SYMBOL_ARCHIVE}" \ michael@0: ${SYMBOL_SERVER_USER}@${SYMBOL_SERVER_HOST}:"${SYMBOL_SERVER_PATH}/${archive}" michael@0: echo "Unpacking symbols on remote host..." michael@0: ssh -2 ${SYMBOL_SERVER_PORT:+-p $SYMBOL_SERVER_PORT} \ michael@0: ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} \ michael@0: -l ${SYMBOL_SERVER_USER} ${SYMBOL_SERVER_HOST} \ michael@0: "set -e; michael@0: umask 0022; michael@0: cd ${SYMBOL_SERVER_PATH}; michael@0: unzip -n '$archive'; michael@0: rm -v '$archive';" michael@0: if test -n "$POST_SYMBOL_UPLOAD_CMD"; then michael@0: echo "${POST_SYMBOL_UPLOAD_CMD} \"${SYMBOL_SERVER_PATH}/${SYMBOL_INDEX_NAME}\"" michael@0: ssh -2 ${SYMBOL_SERVER_PORT:+-p $SYMBOL_SERVER_PORT} \ michael@0: ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} \ michael@0: -l ${SYMBOL_SERVER_USER} ${SYMBOL_SERVER_HOST} \ michael@0: "${POST_SYMBOL_UPLOAD_CMD} \"${SYMBOL_SERVER_PATH}/${SYMBOL_INDEX_NAME}\"" michael@0: fi michael@0: echo "Symbol transfer completed"