-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscp
More file actions
executable file
·32 lines (25 loc) · 1.01 KB
/
scp
File metadata and controls
executable file
·32 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
[[ -z "$INFO_LEVEL" ]] && source ./bits/bootstrap/logging
SCP_OUTPUT=/tmp/scp_output.log
PEM_FILENAME=./assets/ssh/$SERVER.pem
DOWNLOAD_FILENAME=$TO_DIR/$FILENAME
if [[ -e "$PEM_FILENAME.readme" ]] && [[ ! -e "$PEM_FILENAME.pem" ]]; then
error "MISSING $PEM_FILENAME, unable to access $SERVER"
exit 1
fi
notify " -- Downloading $FILENAME from $DIR/$FILENAME to $DOWNLOAD_FILENAME"
if [[ -e "$DOWNLOAD_FILENAME" ]]; then
debug " -- Already downloaded $DOWNLOAD_FILENAME, delete to force a new download"
else
if [[ -e "$PEM_FILENAME" ]]; then
debug " -- Loading private key from ./assets/ssh/$SERVER.pem"
SCRIPT_OUTPUT=$(scp -i $PEM_FILENAME $SERVER:$DIR/$FILENAME $TO_DIR > $SCP_OUTPUT 2>&1)
else
debug " -- Running scp without private pem (if needed, please add it to $PEM_FILENAME)"
SCRIPT_OUTPUT=$(scp $SERVER:$DIR/$FILENAME $TO_DIR > $SCP_OUTPUT 2>&1)
fi
if [[ ! -e "$DOWNLOAD_FILENAME" ]]; then
error "Unable to copy $FILENAME from $SERVER:$DIR/$FILENAME"
exit 1
fi
fi