-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy
More file actions
executable file
·69 lines (58 loc) · 1.66 KB
/
Copy pathdeploy
File metadata and controls
executable file
·69 lines (58 loc) · 1.66 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
62
63
64
65
66
67
68
#!/bin/sh
#set -x
if [ $# -ne 2 ]
then
echo "Usage: deploy <command> <id>"
echo "Commands:"
echo " put: Put the file(s) to the deploy target"
echo " get: Get the file(s) from the deploy target"
echo " edit: Open the local file in an editor"
echo " diff: Show the diff between the local and the deployed file"
echo
exit 1
fi
ID=$2
CMD=$1
EDITOR=vim
# DIFF="diff --report-identical-files --side-by-side --suppress-common-lines"
DIFF=vimdiff
if [ ! -f ".deployrc" ]
then
echo "Could not find configuration file '.deployrc' in current directory"
exit 2
fi
cat ".deployrc"|while read line
do
matches=$(expr match "$line" "^[^:]\+: *\"[^\"]\+\" *-> *\"[^\"]\+\" *$")
[ $? -eq 0 ] || continue
id=$(expr "$line" : "^\([^:]\+\):.*")
src=$(expr "$line" : "^[^:]\+: *\"\([^\"]\+\)\" *->.*")
dst=$(expr "$line" : "^[^:]\+: *\"[^\"]\+\" *-> *\"\([^\"]\+\)\"")
if [ "${ID}" = "${id}" ]
then
case $CMD in
"put" )
echo deploying $src to $dst
scp -r "${src}" "${dst}"
;;
"get" )
echo getting $dst to $src
scp -r "${dst}" "${src}"
;;
"edit" )
$EDITOR "${src}" < /dev/tty
;;
"diff" )
tempFile=$(mktemp)
scp "${dst}" "${tempFile}"
echo "Opening ${dst} as ${tempFile}"
$DIFF "${src}" "${tempFile}" < /dev/tty
rm "${tempFile}"
;;
* )
echo "Invalid command: $CMD"
exit 3
;;
esac
fi
done