|
1 #!/bin/bash |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 # |
|
7 # This script expects the following environment variables to be set: |
|
8 # SYMBOL_SERVER_HOST : host to upload symbols to |
|
9 # SYMBOL_SERVER_USER : username on that host |
|
10 # SYMBOL_SERVER_PATH : path on that host to put symbols in |
|
11 # |
|
12 # And will use the following optional environment variables if set: |
|
13 # SYMBOL_SERVER_SSH_KEY : path to a ssh private key to use |
|
14 # SYMBOL_SERVER_PORT : port to use for ssh |
|
15 # POST_SYMBOL_UPLOAD_CMD: a commandline to run on the remote host after |
|
16 # uploading. The full path of the symbol index |
|
17 # file will be appended to the commandline. |
|
18 # |
|
19 # The script expects two command-line arguments, in this order: |
|
20 # - The symbol index name |
|
21 # - The symbol archive |
|
22 # |
|
23 |
|
24 set -e |
|
25 |
|
26 : ${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"} |
|
27 |
|
28 SYMBOL_INDEX_NAME="$1" |
|
29 SYMBOL_ARCHIVE="$2" |
|
30 |
|
31 hash=`openssl dgst -sha1 "${SYMBOL_ARCHIVE}" | sed 's/^.*)=//' | sed 's/\ //g'` |
|
32 archive="${hash}-"`basename "${SYMBOL_ARCHIVE}" | sed 's/\ //g'` |
|
33 echo "Transferring symbols... ${SYMBOL_ARCHIVE}" |
|
34 scp -oLogLevel=DEBUG -oRekeyLimit=10M ${SYMBOL_SERVER_PORT:+-P $SYMBOL_SERVER_PORT} \ |
|
35 ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} "${SYMBOL_ARCHIVE}" \ |
|
36 ${SYMBOL_SERVER_USER}@${SYMBOL_SERVER_HOST}:"${SYMBOL_SERVER_PATH}/${archive}" |
|
37 echo "Unpacking symbols on remote host..." |
|
38 ssh -2 ${SYMBOL_SERVER_PORT:+-p $SYMBOL_SERVER_PORT} \ |
|
39 ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} \ |
|
40 -l ${SYMBOL_SERVER_USER} ${SYMBOL_SERVER_HOST} \ |
|
41 "set -e; |
|
42 umask 0022; |
|
43 cd ${SYMBOL_SERVER_PATH}; |
|
44 unzip -n '$archive'; |
|
45 rm -v '$archive';" |
|
46 if test -n "$POST_SYMBOL_UPLOAD_CMD"; then |
|
47 echo "${POST_SYMBOL_UPLOAD_CMD} \"${SYMBOL_SERVER_PATH}/${SYMBOL_INDEX_NAME}\"" |
|
48 ssh -2 ${SYMBOL_SERVER_PORT:+-p $SYMBOL_SERVER_PORT} \ |
|
49 ${SYMBOL_SERVER_SSH_KEY:+-i "$SYMBOL_SERVER_SSH_KEY"} \ |
|
50 -l ${SYMBOL_SERVER_USER} ${SYMBOL_SERVER_HOST} \ |
|
51 "${POST_SYMBOL_UPLOAD_CMD} \"${SYMBOL_SERVER_PATH}/${SYMBOL_INDEX_NAME}\"" |
|
52 fi |
|
53 echo "Symbol transfer completed" |