summaryrefslogtreecommitdiff
path: root/parabolaweb-update.in
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-23 20:58:18 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-06-23 20:58:18 -0400
commit213a1ffca123ab7bf30ba3af57fff3c5e99f54ea (patch)
treec05b8b4e94365b8ae9b3e6da33d75d88e4a78ea4 /parabolaweb-update.in
parent07bbca11bee7e0ddae32f9e5db8bf03b72def4ab (diff)
clean up the build system
Diffstat (limited to 'parabolaweb-update.in')
-rw-r--r--parabolaweb-update.in93
1 files changed, 93 insertions, 0 deletions
diff --git a/parabolaweb-update.in b/parabolaweb-update.in
new file mode 100644
index 0000000..6a2ad02
--- /dev/null
+++ b/parabolaweb-update.in
@@ -0,0 +1,93 @@
+#!/bin/bash -e
+
+# Copyright (c) 2012-2013 Luke Shumaker <lukeshu@sbcglobal.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. @pkgconffile@
+. libremessages
+
+clean() {
+ cd "$WEBDIR"
+ msg "Purging old .pyc files..."
+ find . -name '*.pyc' -delete
+ if $RUNMAKE; then
+ msg "Purging old GNU Make generated files..."
+ make clean
+ fi
+}
+
+configure() {
+ cd "$WEBDIR"
+ msg "Checking configuration..."
+ 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() {
+ cd "$WEBDIR"
+ msg "Updating database..."
+ msg2 "Running migrations..."
+ ./manage.py migrate
+ if [[ -f devel/management/commands/update_types_permissions.py ]]; then
+ msg2 "Updating permissions..."
+ ./manage.py update_types_permissions
+ fi
+ msg2 "Loading fixtures..."
+ local file
+ for file in */fixtures/*.json; do
+ ./manage.py loaddata "$file" || true
+ done
+}
+
+update-filesystem() {
+ cd "$WEBDIR"
+ msg "Updating filesystem..."
+ if $RUNMAKE; then
+ msg2 "Re-creating GNU Make generated files..."
+ make
+ fi
+ msg2 "Collecting static files..."
+ echo yes | ./manage.py collectstatic -l
+}
+
+main() {
+ if [[ -z "$EDITOR" ]]; then
+ error 'Please set the $EDITOR variable'
+ exit 1
+ fi
+
+ if [[ -d "$WEBDIR" ]]; then
+ clean
+ fi
+ gitget checkout "$GITURL" "$WEBDIR"
+ configure
+ update-database
+ update-filesystem
+}
+
+main "$@"