forked from maxheld83/rsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·47 lines (37 loc) · 1.56 KB
/
entrypoint.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit # same as -e
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
set -o pipefail
printf '\033[33m Warning: This action does not currently support host verification; verification is disabled. \n \033[0m\n'
printf -- 'Setting up SSH... '
ssh_path="$HOME/.ssh"
mkdir "$ssh_path"
touch "$ssh_path/known_hosts"
echo "$SSH_PRIVATE_KEY" > "$ssh_path/deploy_key"
echo "$SSH_PUBLIC_KEY" > "$ssh_path/deploy_key.pub"
chmod 700 "$ssh_path"
chmod 600 "$ssh_path/known_hosts"
chmod 600 "$ssh_path/deploy_key"
chmod 600 "$ssh_path/deploy_key.pub"
eval "$(ssh-agent -s)"
ssh-add "$ssh_path/deploy_key"
printf -- 'Recording known host... '
# below key was created by running the below line from inside karli.rrze
# ssh-keyscan -t ecdsa-sha2-nistp256 karli.rrze.uni-erlangen.de
# below line actually seems ineffectual; we still get "host key verification failed"
echo "$HOST_NAME,$HOST_IP $HOST_FINGERPRINT" \
>> "$ssh_path/known_hosts"
# $HOST_NAME is used in the above as well as in the below; that's why it is an env
ssh -v $LOGIN_USER exit
# "args" from main.workflow get append to below call
# these include source, user, $HOST and target
printf -- 'Uploading assets... '
sh -c "rsync -e 'ssh -o StrictHostKeyChecking=no' $*" > output
cat output
printf -- '\033[32m Deployment successful! \033[0m\n'
printf -- '\n'