diff options
author | Márcio Alexandre Silva Delgado <coadde@lavabit.com> | 2012-10-21 19:51:39 -0200 |
---|---|---|
committer | Márcio Alexandre Silva Delgado <coadde@lavabit.com> | 2012-10-21 19:51:39 -0200 |
commit | ee7f9096475e0ea57d9326d087f94e3df4c6512b (patch) | |
tree | 0e9b42a4cb590b3c59632a91b519e0bacac38bd3 /libre/parabolaweb-utils | |
parent | b4ce63a23bfc79192dfc546c4196ec651dd31393 (diff) | |
parent | b09b1d60e80ef66c0817fcc7466a20ec5a365520 (diff) | |
download | abslibre-ee7f9096475e0ea57d9326d087f94e3df4c6512b.tar.gz abslibre-ee7f9096475e0ea57d9326d087f94e3df4c6512b.tar.bz2 abslibre-ee7f9096475e0ea57d9326d087f94e3df4c6512b.zip |
Merge branch 'master' of ssh://parabolagnulinux.org:1863/srv/git/abslibre
Diffstat (limited to 'libre/parabolaweb-utils')
-rw-r--r-- | libre/parabolaweb-utils/PKGBUILD | 46 | ||||
-rw-r--r-- | libre/parabolaweb-utils/helper.sh | 39 | ||||
-rw-r--r-- | libre/parabolaweb-utils/parabolaweb-fcgi | 12 | ||||
-rw-r--r-- | libre/parabolaweb-utils/parabolaweb-update | 81 | ||||
-rw-r--r-- | libre/parabolaweb-utils/parabolaweb.conf | 3 | ||||
-rw-r--r-- | libre/parabolaweb-utils/parabolaweb.rc | 43 | ||||
-rw-r--r-- | libre/parabolaweb-utils/parabolaweb.service | 10 |
7 files changed, 234 insertions, 0 deletions
diff --git a/libre/parabolaweb-utils/PKGBUILD b/libre/parabolaweb-utils/PKGBUILD new file mode 100644 index 000000000..cfb39d703 --- /dev/null +++ b/libre/parabolaweb-utils/PKGBUILD @@ -0,0 +1,46 @@ +# 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=2 +pkgdesc="Utils for the Parabola website" +arch=('any') +url="https://projects.parabolagnulinux.org/parabolaweb.git/" +license=('GPL2') +depends=('python2' 'python2-flup' 'git' 'libretools' `_get_depends`) +backup=('etc/conf.d/parabolaweb') + +export pkgver + +source=(git://parabolagnulinux.org/parabolaweb.git + parabolaweb-update + parabolaweb-fcgi + parabolaweb.rc + parabolaweb.service + parabolaweb.conf) + +build() { + : +} + +package() { + cd "${srcdir}" + install -Dm755 parabolaweb-update "${pkgdir}/usr/sbin/parabolaweb-update" + install -Dm755 parabolaweb-fcgi "${pkgdir}/usr/sbin/parabolaweb-fcgi" + install -Dm755 parabolaweb.rc "${pkgdir}/etc/rc.d/parabolaweb" + install -Dm644 parabolaweb.service "${pkgdir}/usr/lib/systemd/system/parabolaweb.service" + install -Dm644 parabolaweb.conf "${pkgdir}/etc/conf.d/parabolaweb" +} + +md5sums=('SKIP' + 'dd05d6a4ea7cff7fdd789f59aeb9059a' + '520e20b8bbca64042b3afa76b0bec55f' + '1bce8fb832ad9e61cf8b96426ce843b5' + 'c7e292d2d1c3e846e5cfcd7283de0fe4' + 'fb291168d3f57a85f82216c4e74c9ccf') diff --git a/libre/parabolaweb-utils/helper.sh b/libre/parabolaweb-utils/helper.sh new file mode 100644 index 000000000..5ce4182b3 --- /dev/null +++ b/libre/parabolaweb-utils/helper.sh @@ -0,0 +1,39 @@ +_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 + if [[ -f "${srcdir:-src}/parabolaweb/requirements_prod.txt" ]]; then + 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 + fi +} + +_get_depends_nover() { + _get_depends | sed 's/[<>=].*//' +} diff --git a/libre/parabolaweb-utils/parabolaweb-fcgi b/libre/parabolaweb-utils/parabolaweb-fcgi new file mode 100644 index 000000000..3dec02e10 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb-fcgi @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +. /etc/conf.d/parabolaweb + +[[ -e /srv/http/web/manage.py ]] + +sudo -u "${WEBUSER:-$USER}" python2 /srv/http/web/manage.py runfcgi \ + host=${HOST} \ + port=${PORT} \ + --settings=settings \ + "$@" diff --git a/libre/parabolaweb-utils/parabolaweb-update b/libre/parabolaweb-utils/parabolaweb-update new file mode 100644 index 000000000..e4d65c2d9 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb-update @@ -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 "$@" diff --git a/libre/parabolaweb-utils/parabolaweb.conf b/libre/parabolaweb-utils/parabolaweb.conf new file mode 100644 index 000000000..c53b19cb8 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb.conf @@ -0,0 +1,3 @@ +HOST=127.0.0.1 +PORT=8090 # 80 is nginx +WEBUSER=nobody diff --git a/libre/parabolaweb-utils/parabolaweb.rc b/libre/parabolaweb-utils/parabolaweb.rc new file mode 100644 index 000000000..087a3fcb0 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb.rc @@ -0,0 +1,43 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +PIDFILE=/run/web/parabolaweb.pid + +case $1 in +start) + stat_busy "Starting ParabolaWeb" + if parabolaweb-fcgi pidfile=${PIDFILE}; then + 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/parabolaweb.service b/libre/parabolaweb-utils/parabolaweb.service new file mode 100644 index 000000000..d145e53d8 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb.service @@ -0,0 +1,10 @@ +[Unit] +Description=ParabolaWeb + +[Service] +Type=forking +ExecStart=/usr/sbin/parabolaweb-fcgi pidfile=/run/web/parabolaweb.pid +PIDFile=/run/web/parabolaweb.pid + +[Install] +WantedBy=multi-user.target |