-
Notifications
You must be signed in to change notification settings - Fork 2
/
update_website
executable file
·53 lines (46 loc) · 1.73 KB
/
update_website
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
#!/bin/sh
#vim:set expandtab sts=4 ts=4 sw=4 tw=80:
# This script helps to automate the process of regenerating the static
# freedict.org web site with the latest dynamic content provided by its plugins.
# It assumes that it is run on the FreeDict server. There should be a base path
# for the API files and another for the HTML files. The reason to keep it
# separate is that lektor clean removes all files in the www directory. This
# script copies files from to the $API_BASE.
# WARNING: this script drops changes in i18n/contents+<langcode>.po, because
# these are usually only date changes. If you happen to have changes there,
# commit them first!
set -e
# where freedict-database.* is found
API_BASE=/var/www
WWW_BASE=/var/www/html
if ! [ -f $API_BASE/freedict-database.json ]; then
echo "Error, freedict-database.json not found, please make sure that it's in $API_BASE or adjust the path in this script."
exit 1
fi
export LC_ALL=en_US.UTF-8
export PATH="$HOME/.local/bin:$PATH"
# change to directory where this script dwells
SCRIPT_PATH=$(readlink -f "$0")
cd $(dirname "$SCRIPT_PATH")
if [ ! -f freedict-database.json ]; then
ln -s -f $API_BASE/freedict-database.json
fi
# drop changes, it's only the latest generation date which changed
git checkout i18n/contents+*.po
git pull -r > /dev/null 2>&1
lektor clean --yes --output-path $WWW_BASE.tmp > /dev/null || true
LEKTOR_LOG=/tmp/lektor_build.log
lektor build --output-path $WWW_BASE.tmp > $LEKTOR_LOG 2>&1
RET=$?
if [ $RET -ne 0 ] || grep -E '^[[:space:]]+E ' < $LEKTOR_LOG > /dev/null; then
cat $LEKTOR_LOG
exit $RET
fi
# copy API files
cd $WWW_BASE.tmp
cp $API_BASE/freedict-database.json .
cp $API_BASE/freedict-database.xml .
cd ..
rm -rf $WWW_BASE
mv $WWW_BASE.tmp $WWW_BASE
exit 0