-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpush.sh
executable file
·83 lines (65 loc) · 1.71 KB
/
push.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
#~ set -x
GIT_SOURCESDIR=${HOME}"/.tmp/geany-plugins/" # should be same as $SOURCESDIR in gencontent.sh
SOURCEDIR="/home/dmaphy/webroot/websites/plugins.geany.org/"
PREVIEWDIR="/home/dmaphy/plugins.geany.org_preview/"
STABLEDIR="/home/dmaphy/plugins.geany.org_stable/"
BACKUPDIR="/home/dmaphy/plugins.geany.org.backup/"
EXCLUDE=".svn gencontent* *.sh rst2html* templates *.conf addons geany-plugins geanydoc geanylua geanyprj geanyvc spellcheck"
if [ ! -d $SOURCEDIR ]; then
echo "Could not find $SOURCEDIR. Exiting..";
exit 127;
fi
catch_error()
{
RC=$1;
if [ $RC -eq 0 ]; then
echo "done."
else
echo "failed. Exiting...";
exit 127;
fi
}
if [ ! -d $PREVIEWDIR ]; then
echo "Could not find $PREVIEWDIR. Trying to create...";
mkdir -p $PREVIEWDIR;
catch_error $?;
fi
if [ ! -d $STABLEDIR ]; then
echo "Could not find $STABLEDIR. Trying to create...";
mkdir -p $STABLEDIR;
catch_error $?;
fi
if [ ! -d $BACKUPDIR ]; then
echo "Could not find $BACKUPDIR. Trying to create...";
mkdir -p $BACKUPDIR;
catch_error $?;
fi
EXARG=""
for i in $EXCLUDE;
do
EXARG="$EXARG --exclude $i";
done
if [ -z $1 ]; then
echo "Usage: $0 [preview|stable]";
else
case $1 in
"preview")
# backup is not necessary, when pushing to preview..
rsync -avC $EXARG --delete $SOURCEDIR $PREVIEWDIR
;;
"stable")
# check if $STABLEDIR is empty and backup if it is not
ls $STABLEDIR/* > /dev/null 2>&1;
if [ $? -eq 0 ]; then
rsync -avC $EXARG --delete $STABLEDIR $BACKUPDIR
fi
rsync -avC $EXARG --delete $PREVIEWDIR $STABLEDIR
# hack for images for the Markdown plugin
rsync -avC ${GIT_SOURCESDIR}markdown/docs/*.png $STABLEDIR
;;
*)
echo "Usage: $0 [preview|stable]";
;;
esac
fi