-
Notifications
You must be signed in to change notification settings - Fork 12
/
cron.sh
executable file
·87 lines (78 loc) · 2.38 KB
/
cron.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
84
85
86
87
#!/bin/bash
BASEDIR="/home/counter.opensuse.org/svg"
LOCAL="/home/counter.opensuse.org/output"
BINARY_LOCATION="https://raw.github.com/openSUSE/artwork/master/Marketing%20Materials/Events/openSUSE%20Conference/2013-oS-Conference/countdown-banner"
BINARY_FINAL_DATE=$(date -d "2014-11-04" +%s)
set -e
VERBOSE=
RENDER=
GIT_PULL=
while getopts 'vREBG' v; do
case $v in
v) VERBOSE=1;;
E) RENDER=1;;
B) BINARY=1;;
G) GIT_PULL=1;;
*) echo "ERROR: unsupported parameter -$v">&2; exit 1;;
esac
done
shift $(( $OPTIND - 1 ))
RFLAGS=""
[ -n "$VERBOSE" ] && RFLAGS="$RFLAGS -v"
if [ -n "$GIT_PULL" ]; then
cd "$BASEDIR"
GFLAGS=""
[ -n "$VERBOSE" ] && GFLAGS="$GFLAGS --verbose"
git pull -q --ff-only $GFLAGS
fi
mkdir -p "$LOCAL"
/bin/rm -f "$LOCAL"/*.png
if [ -n "$RENDER" ]; then
cd "$BASEDIR"
./render.py $RFLAGS -k "$LOCAL"/ || exit 1
pushd "$LOCAL" >/dev/null
find . -maxdepth 1 -type f -name '*.png' | while read png; do
[ -n "$VERBOSE" ] && echo "optipng $png"
optipng "$png" &>/dev/null
done
popd >/dev/null
for i in *-label.svg ; do
cp $i "$LOCAL"/${i//-label} ;
done
./mkhtml.pl "$LOCAL"/
for f in *.html *.css *.js; do
[ -e "$f" ] || continue
cp -a "$f" "$LOCAL/"
done
pushd "$LOCAL/" > /dev/null
shopt -s nullglob
copied=
for i in *-label*.png ; do
j=${i//-label}
if [ ! -e $j ] ; then
ln -s $i ${i//-label} ;
fi
copied=1
done
shopt -u nullglob
if [ ! -n "$copied" ]; then
echo "There seems to be no generated images. Please check the output of \"./render.py $RFLAGS $LOCAL/\""
exit 1
fi
popd > /dev/null
fi
if [ -n "$BINARY" ]; then
/bin/rm -f "$LOCAL"/*.png
TODAY=$(date +%s)
days_left=$(printf "%02d" $(($(($BINARY_FINAL_DATE-$TODAY+86400))/86400)))
[ $days_left -le 00 ] && days_left=00
for size in large medium small; do
wget "${BINARY_LOCATION}/${days_left}-$size.png" -P "$LOCAL"
ln -s "${days_left}-$size.png" "$LOCAL/$size.$lang.png"
for lang in en de cs sk fr da ru pl nl fi es it el sv hr nb pt pt_BR hu ro si cn tw id bg ja wa gl ge lt tr; do
for suffix in label nolabel; do
ln -s "${days_left}-$size.png" "$LOCAL/$size-$suffix.$lang.png"
done
done
done
fi