forked from Nitrokey/nitrokey-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply_translated_content.sh
83 lines (64 loc) · 3.8 KB
/
apply_translated_content.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
# deactivate
#echo "$(date) [apply_translated_content.sh] DEACTIVATED.." >> /var/www/sphinx/logs_sphinx/webhook.log & exit
# Load Variables and Language Codes
source /var/www/sphinx/sphinx/nitrokey-documentation/config.sh
if [ $? -ne 0 ]
then
echo "Building Docs.nitrokey.com – [apply_translated_content.sh] config.sh not loaded correctly." | mail -s "[Sphinx] ($BASHPID) Error Loading Config File." $admin_mail_address
echo "$(date) [apply_translated_content.sh] ($BASHPID) Error loading config.sh" >> /var/www/sphinx/logs_sphinx/webhook.log
exit
fi
echo "$(date) [apply_translated_content.sh] ($BASHPID) Pulling Repo..." >> /var/www/sphinx/logs_sphinx/webhook.log
cd /var/www/sphinx/sphinx/nitrokey-documentation
# pull new content
git pull
if [ $? -eq 0 ]
then
echo "$(date) [apply_translated_content.sh] ($BASHPID) Pulling Repo...DONE" >> /var/www/sphinx/logs_sphinx/webhook.log
else
echo "$(date) [apply_translated_content.sh] ($BASHPID) Pulling Repo...FAILED" >> /var/www/sphinx/logs_sphinx/webhook.log
echo "Building Docs.nitrokey.com – pulling repo FAILED." | mail -s "[Sphinx] ($BASHPID) Pulling Repo FAILED." $admin_mail_address
fi
# build all language versions
echo "$(date) [apply_translated_content.sh] ($BASHPID) Building language versions (mode $build_mode)." >> /var/www/sphinx/logs_sphinx/webhook.log
for lang in "${languages[@]}"
do
echo "$(date) [apply_translated_content.sh] ($BASHPID) (SPHINX) Building Language Version $lang..." >> /var/www/sphinx/logs_sphinx/webhook.log
if [ $build_mode == "full" ]
then
if [ -d "/var/www/sphinx/www/docs.nitrokey.com_$lang-temp" ]
then
echo "$(date) [apply_translated_content.sh] ($BASHPID) (SPHINX) Building Language Version $lang SKIPPED. (Directory not empty. Another build process may be running)" >> /var/www/sphinx/logs_sphinx/webhook.log
echo "Building was skipped, as the temporary directory /var/www/sphinx/www/docs.nitrokey.com_$lang-temp already existed. Something may have gone wrong earlier or another build process was running at the same time. The directory should be deleted before the next build." | mail -s "[Sphinx] ($BASHPID) Warning - Building Language $lang." $admin_mail_address
else
sphinx-build -a -D language="$lang" -b html /var/www/sphinx/sphinx/nitrokey-documentation/ /var/www/sphinx/sphinx/sphinx_build_temp/$lang-temp
status=$?
fi
elif [ $build_mode == "incremental" ]
then
sphinx-build -D language="$lang" -b html /var/www/sphinx/sphinx/nitrokey-documentation/ /var/www/sphinx/sphinx/sphinx_build_temp/$lang-temp
status=$?
else
echo "Building Docs.nitrokey.com Language $lang FAILED. Sphinx build mode in config.sh unkown." | mail -s "[Sphinx] ($BASHPID) Building Language $lang FAILED." $admin_mail_address
fi
if [ $status -eq 0 ]
then
echo "$(date) [apply_translated_content.sh] ($BASHPID) (SPHINX) Building Language Version $lang...DONE" >> /var/www/sphinx/logs_sphinx/webhook.log
if [ $build_mode == "full" ]
then
rm /var/www/sphinx/www/static/$lang
mv /var/www/sphinx/sphinx/sphinx_build_temp/$lang-temp /var/www/sphinx/www/static/$lang
elif [ $build_mode == "incremental" ]
then
# small downtime
cp /var/www/sphinx/sphinx/sphinx_build_temp/$lang-temp /var/www/sphinx/www/static/ -r
rm -r /var/www/sphinx/www/static/$lang
mv /var/www/sphinx/www/static/$lang-temp /var/www/sphinx/www/static/$lang
fi
else
echo "$(date) [apply_translated_content.sh] ($BASHPID) (SPHINX) Building Language Version $lang...FAILED" >> /var/www/sphinx/logs_sphinx/webhook.log
echo "Building Docs.nitrokey.com Language $lang FAILED. The online version was not altered." | mail -s "[Sphinx] ($BASHPID) Building Language $lang FAILED." $admin_mail_address
fi
done
echo "$(date) [apply_translated_content.sh] ($BASHPID) Atempts to buil all languages DONE." >> /var/www/sphinx/logs_sphinx/webhook.log