forked from sagebind/docker-swarm-deploy-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·38 lines (30 loc) · 1.01 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
#!/bin/sh
set -eu
if [ -z "$INPUT_REMOTE_HOST" ]; then
echo "Input remote_host is required!"
exit 1
fi
# Extra handling for SSH-based connections.
if [ ${INPUT_REMOTE_HOST#"ssh://"} != "$INPUT_REMOTE_HOST" ]; then
SSH_HOST=${INPUT_REMOTE_HOST#"ssh://"}
SSH_HOST=${SSH_HOST#*@}
if [ -z "$INPUT_SSH_PRIVATE_KEY" ]; then
echo "Input ssh_private_key is required for SSH hosts!"
exit 1
fi
if [ -z "$INPUT_SSH_PUBLIC_KEY" ]; then
echo "Input ssh_public_key is required for SSH hosts!"
exit 1
fi
echo "Registering SSH keys..."
# Save private key to a file and register it with the agent.
mkdir -p "$HOME/.ssh"
echo "$INPUT_SSH_PRIVATE_KEY" > "$HOME/.ssh/docker"
chmod 600 "$HOME/.ssh/docker"
eval $(ssh-agent)
ssh-add "$HOME/.ssh/docker"
# Add public key to known hosts.
echo "$INPUT_SSH_PUBLIC_KEY" >> /etc/ssh/ssh_known_hosts
fi
echo "Connecting to $INPUT_REMOTE_HOST..."
docker --log-level debug --host "$INPUT_REMOTE_HOST" "$@" 2>&1