-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·61 lines (49 loc) · 1.36 KB
/
deploy.sh
File metadata and controls
executable file
·61 lines (49 loc) · 1.36 KB
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
#!/bin/bash
set -e
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) <host> [--config] [--code] [--media]" >&2
exit 1
fi
DEPLOY_HOST="$1"
DEPLOY_USER="${DEPLOY_USER:-pi}"
DEPLOY_DIR=/srv/crosswalk/code
DEPLOY_DEST="${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_DIR}"
ssh_sudo() {
ssh "${DEPLOY_USER}@${DEPLOY_HOST}" "sudo $@"
}
echo "Switching permissions during deploy..."
ssh_sudo chown -R $DEPLOY_USER $DEPLOY_DIR
shift
if [[ $# -eq 0 ]]; then
SYNC_CONFIG=1
SYNC_CODE=1
SYNC_MEDIA=1
else
for opt in $@; do
case $opt in
--config) SYNC_CONFIG=1 ;;
--code) SYNC_CODE=1 ;;
--media) SYNC_MEDIA=1 ;;
*)
echo "Unknown option: $opt" >&2
exit 1
esac
done
fi
if [[ $SYNC_CONFIG ]]; then
echo "Copying config to ${DEPLOY_HOST}"
scp config.yml $DEPLOY_DEST/config.yml
fi
if [[ $SYNC_CODE ]]; then
echo "Copying code to ${DEPLOY_HOST}"
rsync -rz --delete xwalk templates config.yml run.py button.py $DEPLOY_DEST
fi
if [[ $SYNC_MEDIA ]]; then
echo "Copying media to ${DEPLOY_HOST}"
rsync -rz --progress --delete static/ $DEPLOY_DEST/static/
fi
echo "Resetting permissions..."
ssh_sudo chown -R crosswalk:crosswalk $DEPLOY_DIR
echo "Restarting crosswalk and button service"
ssh_sudo systemctl restart button
ssh_sudo systemctl restart crosswalk