forked from 2600hz/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync_to_remote.bash
executable file
·37 lines (27 loc) · 982 Bytes
/
sync_to_remote.bash
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
## copies changed files (the beam code) to a host/path
## Usage:
## ./sync_to_remote.bash
## Syncs all files that diff from origni/master
## ERL_FILES=$(git diff --name-only origin/{BRANCH} *.erl) HOST="{SERVER}" ./scripts/sync_to_remote.bash
## Sync any unpushed changes to HOST
pushd $(dirname $0) > /dev/null
cd $(pwd -P)/..
ERL_FILES=${ERL_FILES:-$(git --no-pager diff --name-only HEAD origin/master -- applications core | grep erl)}
HOST=${HOST:-"192.168.1.186"}
PORT=${PORT:-"22"}
BEAM_PATH=${BEAM_PATH:-"/tmp/beams"}
function erl_to_beam {
APP_PATH=${1%%/src*} ## core/APP or applications/APP
BASENAME=${1##*/} ## file.erl
BEAM_FILE=${BASENAME/erl/beam} ## file.beam
echo "$APP_PATH/ebin/$BEAM_FILE"
}
[[ ! -z $ERL_FILES ]] && echo -n "syncing "
for ERL in $ERL_FILES; do
BEAM=$(erl_to_beam $ERL)
echo -n "."
[ -f $BEAM ] && $(scp -P$PORT "$BEAM" "$HOST:$BEAM_PATH")
done
echo " done"
popd > /dev/null