blob: 62d3eed7cf67d8ba81226d91e3f98738ee086dea (
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
|
#!/bin/bash
DATE=$(date +%F)
LOG_DATE=$(date +%F-%R)
BASE_DIR="/var/www/planet.gentoo.org/" # created by cfengine
RESTRICT=""
VENUS_DIR="/usr/lib/python2.6/site-packages/venus/"
# Create folders and symlinks (for initial setup)
[[ -d ${BASE_DIR}htdocs ]] || mkdir ${BASE_DIR}htdocs
[[ -d ${BASE_DIR}logs/planet ]] || mkdir -p ${BASE_DIR}logs/planet
[[ -d ${BASE_DIR}logs/universe ]] || mkdir -p ${BASE_DIR}logs/universe
[[ -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 -p ${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
# Get latest Git changes
cd ${BASE_DIR}planet-gentoo; git pull --force >/dev/null 2>&1
# Run Venus
for x in planet universe; do
if [[ ! -z $RESTRICT ]]; then
for y in $RESTRICT; do
rm -f ${BASE_DIR}planet-gentoo/configs/${x}/${y}
done
fi
cat ${BASE_DIR}planet-gentoo/configs/base/venus.${x} ${BASE_DIR}planet-gentoo/configs/${x}/* > ${BASE_DIR}generated_configs/venus.${x}.ini
python ${VENUS_DIR}planet.py ${BASE_DIR}generated_configs/venus.${x}.ini > ${BASE_DIR}logs/${x}/${LOG_DATE}.log 2>&1
done
rm -f ${BASE_DIR}generated_configs/venus.{planet,universe}.ini
# Delete old logs
find ${BASE_DIR}logs -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
|