-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·49 lines (43 loc) · 871 Bytes
/
deploy.sh
File metadata and controls
executable file
·49 lines (43 loc) · 871 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
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env bash
set -e
while [[ $# -gt 0 ]]; do
case $1 in
--host)
host="$2"
shift
shift
;;
--bundle)
bundle="$2"
shift
shift
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "Unknown positional $1"
exit 1
;;
esac
done
# exceptions
if [ -z "$host" ]; then
echo "--host required" >&2
exit 1
fi
if [ -z "$bundle" ]; then
echo "--bundle required" >&2
exit 1
fi
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
bundletar=$(basename ${bundle})
bundledir=${bundletar%.tar.gz}
targettmp=/tmp/${timestamp}
sshhost=root@${host}
ssh ${sshhost} "mkdir ${targettmp}"
scp ${bundle} ${sshhost}:${targettmp}
ssh ${sshhost} "tar -xv -C ${targettmp} -f ${targettmp}/${bundletar}"
ssh ${sshhost} "${targettmp}/${bundledir}/install.sh"
ssh ${sshhost} "rm -r ${targettmp}"