summaryrefslogtreecommitdiff
path: root/libre/parabolaweb-utils
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-10-20 17:49:49 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-10-20 17:49:49 -0400
commitf7f89bc6ad82ad0ce83a0bf35edcc05957dfbc63 (patch)
treeb21a5bbfeeaf27effe276bfe53e0deb731af07b7 /libre/parabolaweb-utils
parent358e6bb02ffb3b79168f87b9905584ee1a1969c0 (diff)
downloadabslibre-f7f89bc6ad82ad0ce83a0bf35edcc05957dfbc63.tar.gz
abslibre-f7f89bc6ad82ad0ce83a0bf35edcc05957dfbc63.tar.bz2
abslibre-f7f89bc6ad82ad0ce83a0bf35edcc05957dfbc63.zip
redo libre/parabolaweb-git into libre/parabolaweb-utils
Diffstat (limited to 'libre/parabolaweb-utils')
-rw-r--r--libre/parabolaweb-utils/PKGBUILD37
-rw-r--r--libre/parabolaweb-utils/helper.sh37
-rw-r--r--libre/parabolaweb-utils/parabolaweb.init.sh51
-rw-r--r--libre/parabolaweb-utils/update-parabolaweb81
4 files changed, 206 insertions, 0 deletions
diff --git a/libre/parabolaweb-utils/PKGBUILD b/libre/parabolaweb-utils/PKGBUILD
new file mode 100644
index 000000000..3b57c5d13
--- /dev/null
+++ b/libre/parabolaweb-utils/PKGBUILD
@@ -0,0 +1,37 @@
+# Maintainer: Luke Shumaker <lukeshu@sbcglobal.net>
+
+. helper.sh
+# provides:
+# _get_pkgver
+# _get_depends
+# _get_depends_nover (no version requirements)
+
+pkgname=parabolaweb-utils
+pkgver=`_get_pkgver`
+pkgrel=1
+pkgdesc="Utils for the Parabola website"
+arch=('any')
+url="https://projects.parabolagnulinux.org/parabolaweb.git/"
+license=('GPL2')
+depends=('python2' 'git' 'libretools' `_get_depends`)
+
+export pkgver
+
+source=(git://parabolagnulinux.org/parabolaweb.git
+ parabolaweb.init.sh
+ update-parabolaweb)
+
+build() {
+ :
+}
+
+package() {
+ cd "${srcdir}"
+ install -d "${pkgdir}/${_install_dir}"
+ install -Dm755 parabolaweb.init.sh "${pkgdir}/etc/rc.d/parabolaweb"
+ install -Dm755 update-parabolaweb "${pkgdir}/usrls/sbin/update-parabolaweb"
+}
+
+md5sums=('SKIP'
+ 'f52aebbedaa61f688fb2bc626a783003'
+ 'dd05d6a4ea7cff7fdd789f59aeb9059a')
diff --git a/libre/parabolaweb-utils/helper.sh b/libre/parabolaweb-utils/helper.sh
new file mode 100644
index 000000000..d00f83f7f
--- /dev/null
+++ b/libre/parabolaweb-utils/helper.sh
@@ -0,0 +1,37 @@
+_mksource() {
+ if [[ -z _DO_NOT_RUN_MKSOURCE ]]; then
+ _DO_NOT_RUN_MKSOURCE=true makepkg -o
+ fi
+}
+
+_get_pkgver() {
+ if [[ -n $pkgver ]] && [[ $pkgver != 0.bogus ]]; then
+ echo $pkgver
+ else
+ _mksource 1>&2
+ if [[ -f "${srcdir:-src}/parabolaweb/requirements_prod.txt" ]]; then
+ pushd "${srcdir:-src}/parabolaweb" >/dev/null
+ # get the date requirements_prod.txt was last modified
+ gitdate="$(git log -n1 --date=iso --format=format:'%cd' ./requirements_prod.txt)"
+ date -u +%Y%m%d.%H%M -d "$gitdate"
+ popd >/dev/null
+ else
+ echo 0.bogus
+ fi
+ fi
+}
+
+_get_depends() {
+ _mksource 1>&2
+ pushd "${srcdir:-src}" >/dev/null
+ python2_packages='markdown|psycopg2|pyinotify|pytz|south'
+ < parabolaweb/requirements_prod.txt sed -r \
+ -e 's/.*/\L&/' -e 's/==/=/' \
+ -e 's/^python-memcached/python2-memcached/' \
+ -e "s/^(${python2_packages})/python2-&/"
+ popd >/dev/null
+}
+
+_get_depends_nover() {
+ _get_depends | sed 's/[<>=].*//'
+}
diff --git a/libre/parabolaweb-utils/parabolaweb.init.sh b/libre/parabolaweb-utils/parabolaweb.init.sh
new file mode 100644
index 000000000..0ff8ecd7c
--- /dev/null
+++ b/libre/parabolaweb-utils/parabolaweb.init.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+HOST=127.0.0.1
+PORT=8090 # 80 is nginx
+PIDFILE=/var/run/web/fcgi.pid
+
+case $1 in
+start)
+ stat_busy "Starting ParabolaWeb"
+ if [[ -e /srv/http/web/manage.py ]]; then
+ sudo -u nobody \
+ python2 /srv/http/web/manage.py runfcgi \
+ host=${HOST} \
+ port=${PORT} \
+ pidfile=${PIDFILE} \
+ --settings=settings
+ add_daemon parabolaweb
+ stat_done
+ exit 0
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+
+stop)
+ stat_busy "Stopping ParabolaWeb"
+ if [[ -f ${PIDFILE} ]]; then
+ pid=$(cat ${PIDFILE})
+ kill ${pid}
+ rm_daemon parabolaweb
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+
+restart)
+ $0 stop
+ $0 start
+ ;;
+
+*)
+ echo "Usage: $0 {start|stop|restart}" >&2
+ exit 1
+
+esac
diff --git a/libre/parabolaweb-utils/update-parabolaweb b/libre/parabolaweb-utils/update-parabolaweb
new file mode 100644
index 000000000..e4d65c2d9
--- /dev/null
+++ b/libre/parabolaweb-utils/update-parabolaweb
@@ -0,0 +1,81 @@
+#!/bin/bash
+set -e
+
+_install_dir=/srv/http
+_gitname=web
+_gitroot=git://parabolagnulinux.org/parabolaweb.git
+_gitbranch=master
+
+. /usr/bin/libremessages
+
+download() {
+ msg "Connecting to GIT server...."
+ cd "$_install_dir"
+ if [[ -d ${_gitname} ]]; then
+ msg2 "Updating existing tree"
+ cd ${_gitname} && git pull ${_gitroot}
+ else
+ msg2 "Cloning tree"
+ git clone ${_gitroot} ${_gitname}
+ cd ${_gitname}
+ fi
+ git checkout ${_gitbranch}
+ msg "GIT checkout done or server timeout"
+}
+
+clean() {
+ msg "Purging old .pyc files...."
+ cd "$_install_dir/$_gitname"
+ find . -name '*.pyc' -delete
+}
+
+configure() {
+ msg "Checking configuration...."
+ cd "$_install_dir/$_gitname"
+ 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
+}
+
+migrate() {
+ msg "Updating database...."
+ msg2 "Running migrations...."
+ ./manage.py migrate
+ msg2 "Loading fixtures...."
+ ./manage.py loaddata */fixtures/*.json
+}
+
+main() {
+ if [[ -z "$EDITOR" ]]; then
+ error 'Please set the $EDITOR variable'
+ exit 1
+ fi
+
+ [[ ! -d "$_install_dir" ]] && mkdir "$_install_dir"
+
+ download
+ clean
+ configure
+ clean
+ migrate
+
+ msg "Checking media/admin_media symlink...."
+ if [ ! -e media/admin-media ]; then
+ rm media/admin_media
+ ln -s /usr/lib/python2.7/site-packages/django/contrib/admin/media media/admin_media
+ fi
+}
+
+main "$@"