-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
37 lines (28 loc) · 858 Bytes
/
entrypoint.sh
File metadata and controls
37 lines (28 loc) · 858 Bytes
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
#!/bin/bash
set -eu
if [ -z "$INPUT_HOST" ] || [ -z "$INPUT_PORT" ] || [ -z "$INPUT_USERNAME" ] || [ -z "$INPUT_SCRIPT" ]; then
echo "Missing required arguments"
exit 1
fi
if [ -n "$INPUT_PRIVATE_KEY" ] && [ -n "$INPUT_PASSWORD" ]; then
echo "Since you have entered Private Key and Password, Private Key will be used"
fi
if [ -n "$INPUT_PRIVATE_KEY" ]; then
echo "$INPUT_PRIVATE_KEY" > /root/action/server_key
chmod 600 /root/action/server_key
ssh \
-o ConnectTimeout=$INPUT_TIMEOUT \
-o StrictHostKeyChecking=no \
-i /root/action/server_key \
-p $INPUT_PORT \
$INPUT_USERNAME@$INPUT_HOST \
"$INPUT_SCRIPT"
else
sshpass -p "$INPUT_PASSWORD" ssh \
-o ConnectTimeout=$INPUT_TIMEOUT \
-o StrictHostKeyChecking=no \
-p $INPUT_PORT \
$INPUT_USERNAME@$INPUT_HOST \
"$INPUT_SCRIPT"
fi
echo "Done!"