-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy
executable file
·66 lines (51 loc) · 1.37 KB
/
deploy
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -eu
set -o pipefail
shopt -s inherit_errexit
function main() {
local release target_host target_filename args
target_host=""
target_filename="pi_clock"
release="false"
args=()
while [[ "${#}" != 0 ]]; do
case "${1}" in
--release)
release="true"
args+=("--release")
shift 1
;;
--target|-t)
target_host="${2}"
shift 2
;;
--target-filename)
target_filename="${2}"
shift 2
;;
"")
# add all unrecognized arguments to list
args+=("${1}")
shift 1
;;
esac
done
if [[ -z "${target_host}" ]]; then
echo "Error: must provide target host with --target/-t"
exit 1
fi
readonly target_arch=aarch64-unknown-linux-gnu
cross build --target="${target_arch}" --features="rpi-hw" "${args[@]}"
cross test --target="${target_arch}" --features="rpi-hw" "${args[@]}"
if [[ "${release}" == "true" ]]; then
readonly source_path="./target/${target_arch}/release/pi_clock"
else
readonly source_path="./target/${target_arch}/debug/pi_clock"
fi
readonly target_user=pi
readonly target_path="/home/pi/${target_filename}"
rsync ${source_path} ${target_user}@${target_host}:${target_path}
ssh -t ${target_user}@${target_host} ${target_path} --version
echo "Deploy successful"
}
main "${@:-}"