forked from juju/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
juju-sync-charm
executable file
·45 lines (35 loc) · 919 Bytes
/
juju-sync-charm
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
#!/bin/bash
if [ "$1" == "--description" ]; then
echo "Rsync any local changes on unit to a directory"
exit 0
fi
if [ "$1" == "--help" ]; then
echo "usage: juju sync-charm UNIT [DIR]"
echo " UNIT Juju unit with local changes to charm"
echo " DIR Directory to rsync changes to. Default: ."
exit 0
fi
if [ "$1" == "-y" ]; then
FORCE=yes
shift
fi
if [ -z "$1" ]
then
echo "You must provide a unit name" >&2
exit 1
fi
UNIT=$1
DIR=${2:-.}
shift
shift
if [ -z "$FORCE" ]; then
echo "WARNING: This will attempt to merge local changes to the charm on $UNIT into $DIR"
read -p "Continue? [y/N] " doit
if [ "${doit,,}" != "y" ]
then
exit 1
fi
fi
UNITDIR="unit-$(echo $UNIT | sed 's#/#-#')"
REMOTE_DIR="/var/lib/juju/agents/$UNITDIR/charm/"
rsync -Wa --exclude revision --exclude .juju-charm "$@" -e "juju ssh --pty=false $UNIT" :$REMOTE_DIR $DIR