blob: 930dfbb59cecef9740ea21f0198f2980701496bd (
plain)
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
|
#!/bin/bash
DATE=$(date +%F)
LOG_DATE=$(date +%F-%R)
BASE_DIR="/var/www/planet.gentoo.org" # created by cfengine
REPO="${BASE_DIR}/planet-gentoo"
VENUS_DIR="/usr/lib64/python2.7/site-packages/venus"
[[ -d "${VENUS_DIR}" ]] || VENUS_DIR="/usr/lib/python2.7/site-packages/venus"
LOG_DIR="/var/log/planet.gentoo.org"
BANNED_USERS=(
)
# Create folders and symlinks (for initial setup)
[[ -d ${BASE_DIR}/htdocs ]] || mkdir ${BASE_DIR}/htdocs
[[ -d ${BASE_DIR}/generated_configs ]] || mkdir ${BASE_DIR}/generated_configs
[[ -L ${BASE_DIR}/htdocs/images ]] || ln -s ${BASE_DIR}/planet-gentoo/media/* ${BASE_DIR}/htdocs
[[ -d ${BASE_DIR}/htdocs/archives ]] || mkdir ${BASE_DIR}/htdocs/archives
[[ -d ${BASE_DIR}/themes_common ]] || mkdir ${BASE_DIR}/themes_common; \
cp -r /usr/share/webapps/venus/$(ls /usr/share/webapps/venus/ | grep "^20" | sort -r | head -n 1)/themes/common/* ${BASE_DIR}/themes_common/
[[ -d ${BASE_DIR}/htdocs/universe/archives ]] || mkdir -p ${BASE_DIR}/htdocs/universe/archives
[[ -L ${BASE_DIR}/htdocs/archives/index.php ]] || \
ln -s ${BASE_DIR}/planet-gentoo/archives/planet/index.php ${BASE_DIR}/htdocs/archives/index.php
[[ -L ${BASE_DIR}/htdocs/universe/archives/index.php ]] || \
ln -s ${BASE_DIR}/planet-gentoo/archives/universe/index.php ${BASE_DIR}/htdocs/universe/archives/index.php
[[ -L ${BASE_DIR}/htdocs/planet-tyrian.css ]] || \
ln -s ${BASE_DIR}/planet-gentoo/media/planet-tyrian.css ${BASE_DIR}/htdocs
# Get latest Git changes
cd ${BASE_DIR}/planet-gentoo
git reset --hard origin/master > /dev/null 2>&1
git pull --force >/dev/null 2>&1
for instance in planet universe; do
# Remove configs of banned users
for banned_user in ${BANNED_USERS[@]}; do
rm -f ${REPO}/configs/${instance}/${banned_user}
done
# Generate the combined ini file from the split config files
cat ${REPO}/configs/base/venus.${instance} ${REPO}/configs/${instance}/* > ${BASE_DIR}/generated_configs/venus.${instance}.ini
# Run venus
python2 ${VENUS_DIR}/planet.py -v ${BASE_DIR}/generated_configs/venus.${instance}.ini > ${LOG_DIR}/${instance}/${LOG_DATE}.log 2>&1
done
# Delete old logs
find ${LOG_DIR} -type f -mtime +30 -delete
# Check for year directory, if not there create both needed
[[ -d ${BASE_DIR}/htdocs/archives/$(date +%G) ]] || \
mkdir ${BASE_DIR}/htdocs/{,universe/}archives/$(date +%G)
# Archive posts, use -a to retain readable permissions
cp -a ${BASE_DIR}/htdocs/index.html \
${BASE_DIR}/htdocs/archives/$(date +%G)/${DATE}.html
cp -a ${BASE_DIR}/htdocs/universe/index.html \
${BASE_DIR}/htdocs/universe/archives/$(date +%G)/${DATE}.html
cd ${BASE_DIR}/htdocs/archives
php index.php > index.html.gen
[[ $? == 0 ]] && mv index.html.gen index.html
cd ${BASE_DIR}/htdocs/universe/archives
php index.php > index.html.gen
[[ $? == 0 ]] && mv index.html.gen index.html
|