-
Notifications
You must be signed in to change notification settings - Fork 166
/
_promote.sh
executable file
·62 lines (45 loc) · 1.34 KB
/
_promote.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
#!/usr/bin/env bash
set -e
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -z ${srcdir+x} ]; then
echo "\$srcdir is not set"
exit 1
fi
if [ -z ${dstdir+x} ]; then
echo "\$dstdir is not set"
exit 1
fi
if [ -z ${dirmatch+x} ]; then
echo "\$dirmatch is not set"
exit 1
fi
site=$1
version=$2
purge=no
for subdir in $(cd $srcdir && ls); do
if [ -d "${srcdir}/${subdir}" ] && [[ $subdir =~ $dirmatch ]]; then
resha=no
if [ "X${version}" != "X" ] && [ "X${version}" != "X${subdir}" ]; then
continue
fi
for donefile in $(cd ${srcdir}/${subdir} && ls *.done 2> /dev/null); do
doneref=$(echo $donefile | sed 's/\.done$//')
if [[ -f "${srcdir}/${subdir}/${doneref}" || -d "${srcdir}/${subdir}/${doneref}" ]]; then
echo "Promoting ${subdir}/${doneref}..."
mkdir -p "${dstdir}/${subdir}"
rm -rf "${dstdir}/${subdir}/${doneref}"
cp -a "${srcdir}/${subdir}/${doneref}" "${dstdir}/${subdir}/${doneref}"
rm -rf "${srcdir}/${subdir}/${doneref}"
resha=yes
purge=yes
fi
rm -f "${srcdir}/${subdir}/${donefile}"
done
if [ "X${version}" == "X" ] && [ "$resha" == "yes" ]; then
${__dirname}/_resha.sh $site $dstdir $subdir
fi
fi
done
if [ "$purge" == "yes" ]; then
/home/nodejs/queue-cdn-purge.sh $site promote
fi