summaryrefslogtreecommitdiff
path: root/libre/parabolaweb-utils/parabolaweb-update
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2012-11-06 13:37:54 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2012-11-06 13:37:54 -0300
commita48d075b90120462b9f97ab95a224d47e072f7dd (patch)
tree8ba729381a11d91f09b298d888636425c549498b /libre/parabolaweb-utils/parabolaweb-update
parent4ce84837520f8c56ae998d5d2d98380faf3e3eb5 (diff)
parent8ab3c2d0517cb4db3ab2f7635d0b71b701e464ba (diff)
Merge branch 'master' of ssh://gparabola/srv/git/abslibre
Diffstat (limited to 'libre/parabolaweb-utils/parabolaweb-update')
-rw-r--r--libre/parabolaweb-utils/parabolaweb-update80
1 files changed, 80 insertions, 0 deletions
diff --git a/libre/parabolaweb-utils/parabolaweb-update b/libre/parabolaweb-utils/parabolaweb-update
new file mode 100644
index 000000000..45e17c4f2
--- /dev/null
+++ b/libre/parabolaweb-utils/parabolaweb-update
@@ -0,0 +1,80 @@
+#!/bin/bash
+set -e
+
+. /etc/conf.d/parabolaweb
+. /usr/bin/libremessages
+
+find_makefiles() {
+ pushd "$WEBDIR" > /dev/null
+ echo ./sitestatic
+ find . -name static -type d | while read dir; do
+ if [[ -e "$WEBDIR/$dir/Makefile" ]]; then
+ printf '%s\n' "$dir"
+ fi
+ done
+}
+
+clean() {
+ msg "Purging old .pyc files...."
+ cd "$WEBDIR"
+ find . -name '*.pyc' -delete
+ for dir in `find_makefiles`; do
+ make -C "$WEBDIR/$dir" clean
+ done
+}
+
+configure() {
+ msg "Checking configuration...."
+ cd "$WEBDIR"
+ if [[ ! -f local_settings.py ]]; then
+ msg2 "Configuration file missing, opening editor..."
+ cp local_settings.py.example local_settings.tmp.$$.py
+ if "$EDITOR" local_settings.tmp.$$.py; then
+ mv local_settings.tmp.$$.py local_settings.py
+ else
+ rm local_settings.tmp.$$.py
+ msg "Failed to configure, exiting"
+ exit 1
+ fi
+ msg2 "Creating database...."
+ ./manage.py syncdb
+ else
+ msg2 "Current configuration checks out"
+ fi
+}
+
+update-database() {
+ msg "Updating database...."
+ cd "$WEBDIR"
+ msg2 "Running migrations...."
+ ./manage.py migrate
+ msg2 "Loading fixtures...."
+ ./manage.py loaddata */fixtures/*.json
+}
+
+update-filesystem() {
+ msg "Updating filesystem..."
+ for dir in `find_makefiles`; do
+ msg2 "Updating $dir with GNU Make..."
+ make -C "$WEBDIR/$dir"
+ done
+ cd "$WEBDIR"
+ msg2 "Collecting static files..."
+ echo yes | ./manage.py collectstatic -l
+}
+
+main() {
+ if [[ -z "$EDITOR" ]]; then
+ error 'Please set the $EDITOR variable'
+ exit 1
+ fi
+
+ parabolaweb-download
+ clean
+ configure
+ clean
+ update-database
+ update-filesystem
+}
+
+main "$@"