summaryrefslogtreecommitdiff
path: root/libre/parabolaweb-utils
diff options
context:
space:
mode:
Diffstat (limited to 'libre/parabolaweb-utils')
-rw-r--r--libre/parabolaweb-utils/PKGBUILD33
-rw-r--r--libre/parabolaweb-utils/parabolaweb-download47
-rw-r--r--libre/parabolaweb-utils/parabolaweb-fcgi4
-rw-r--r--libre/parabolaweb-utils/parabolaweb-update61
-rw-r--r--libre/parabolaweb-utils/parabolaweb.conf1
-rw-r--r--libre/parabolaweb-utils/parabolaweb.rc1
-rw-r--r--libre/parabolaweb-utils/parabolaweb.service5
7 files changed, 106 insertions, 46 deletions
diff --git a/libre/parabolaweb-utils/PKGBUILD b/libre/parabolaweb-utils/PKGBUILD
index cfb39d703..c1beccdf9 100644
--- a/libre/parabolaweb-utils/PKGBUILD
+++ b/libre/parabolaweb-utils/PKGBUILD
@@ -8,17 +8,24 @@
pkgname=parabolaweb-utils
pkgver=`_get_pkgver`
-pkgrel=2
+pkgrel=4
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`)
+depends=(
+ 'python2' # duh
+ 'python2-flup' # for fcgi
+ 'postgresql' # for database
+ 'git' # used in parabolaweb-update
+ 'libretools' # used in parabolaweb-update
+ `_get_depends`)
backup=('etc/conf.d/parabolaweb')
export pkgver
source=(git://parabolagnulinux.org/parabolaweb.git
+ parabolaweb-download
parabolaweb-update
parabolaweb-fcgi
parabolaweb.rc
@@ -31,16 +38,18 @@ 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"
+ install -Dm755 parabolaweb-download "${pkgdir}/usr/sbin/parabolaweb-download"
+ 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')
+ '01bed679a4fd768e720bfd0f3c7d6694'
+ 'a73063b14746720b77fdbab851f5c161'
+ 'd5294495f42df29d29519ebd0a8f6093'
+ 'cc15e153f99fba82e7bb032896f655c2'
+ 'a468016a7155b5da46521dcfc6428384'
+ '9b565ef07e44d395bf7a0e484e3d19d1')
diff --git a/libre/parabolaweb-utils/parabolaweb-download b/libre/parabolaweb-utils/parabolaweb-download
new file mode 100644
index 000000000..823a18811
--- /dev/null
+++ b/libre/parabolaweb-utils/parabolaweb-download
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+. /etc/conf.d/parabolaweb
+. /usr/bin/libremessages
+
+dir=$WEBDIR
+repo=git://parabolagnulinux.org/parabolaweb.git
+ref=master
+
+cd_safe() {
+ if ! cd "$1"; then
+ error "$(gettext "Failed to change to directory %s")" "$1"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+}
+
+download_git() {
+ if [[ ! -d "$dir/.git" ]] ; then
+ msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
+ if ! git clone "$repo" "$dir"; then
+ error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+ else
+ cd_safe "$dir"
+ # Make sure we are fetching the right repo
+ # if [[ "$repo" != "$(git config --get remote.origin.url)" ]] ; then
+ # error "$(gettext "%s is not a clone of %s")" "$dir" "$repo"
+ # plain "$(gettext "Aborting...")"
+ # exit 1
+ # fi
+ msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
+ if ! git pull origin "$ref"; then
+ # only warn on failure to allow offline builds
+ warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
+ fi
+ fi
+}
+
+main() {
+ [[ -d "${dir%/*}" ]] || mkdir -p "${dir%/*}"
+ download_git
+}
+
+main "$@"
diff --git a/libre/parabolaweb-utils/parabolaweb-fcgi b/libre/parabolaweb-utils/parabolaweb-fcgi
index 3dec02e10..e42aec3cd 100644
--- a/libre/parabolaweb-utils/parabolaweb-fcgi
+++ b/libre/parabolaweb-utils/parabolaweb-fcgi
@@ -3,9 +3,9 @@ set -e
. /etc/conf.d/parabolaweb
-[[ -e /srv/http/web/manage.py ]]
+[[ -e ${WEBDIR}/manage.py ]]
-sudo -u "${WEBUSER:-$USER}" python2 /srv/http/web/manage.py runfcgi \
+sudo -u "${WEBUSER:-$USER}" python2 "${WEBDIR}/manage.py" runfcgi \
host=${HOST} \
port=${PORT} \
--settings=settings \
diff --git a/libre/parabolaweb-utils/parabolaweb-update b/libre/parabolaweb-utils/parabolaweb-update
index e4d65c2d9..45e17c4f2 100644
--- a/libre/parabolaweb-utils/parabolaweb-update
+++ b/libre/parabolaweb-utils/parabolaweb-update
@@ -1,37 +1,31 @@
#!/bin/bash
set -e
-_install_dir=/srv/http
-_gitname=web
-_gitroot=git://parabolagnulinux.org/parabolaweb.git
-_gitbranch=master
-
+. /etc/conf.d/parabolaweb
. /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"
+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 "$_install_dir/$_gitname"
+ cd "$WEBDIR"
find . -name '*.pyc' -delete
+ for dir in `find_makefiles`; do
+ make -C "$WEBDIR/$dir" clean
+ done
}
configure() {
msg "Checking configuration...."
- cd "$_install_dir/$_gitname"
+ cd "$WEBDIR"
if [[ ! -f local_settings.py ]]; then
msg2 "Configuration file missing, opening editor..."
cp local_settings.py.example local_settings.tmp.$$.py
@@ -49,33 +43,38 @@ configure() {
fi
}
-migrate() {
+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
- [[ ! -d "$_install_dir" ]] && mkdir "$_install_dir"
-
- download
+ parabolaweb-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
+ update-database
+ update-filesystem
}
main "$@"
diff --git a/libre/parabolaweb-utils/parabolaweb.conf b/libre/parabolaweb-utils/parabolaweb.conf
index c53b19cb8..467e62e2c 100644
--- a/libre/parabolaweb-utils/parabolaweb.conf
+++ b/libre/parabolaweb-utils/parabolaweb.conf
@@ -1,3 +1,4 @@
HOST=127.0.0.1
PORT=8090 # 80 is nginx
+WEBDIR=/srv/http/web
WEBUSER=nobody
diff --git a/libre/parabolaweb-utils/parabolaweb.rc b/libre/parabolaweb-utils/parabolaweb.rc
index 087a3fcb0..5e310b01d 100644
--- a/libre/parabolaweb-utils/parabolaweb.rc
+++ b/libre/parabolaweb-utils/parabolaweb.rc
@@ -8,6 +8,7 @@ PIDFILE=/run/web/parabolaweb.pid
case $1 in
start)
stat_busy "Starting ParabolaWeb"
+ install -dm777 ${PIDFILE%/*}
if parabolaweb-fcgi pidfile=${PIDFILE}; then
add_daemon parabolaweb
stat_done
diff --git a/libre/parabolaweb-utils/parabolaweb.service b/libre/parabolaweb-utils/parabolaweb.service
index d145e53d8..a59d58512 100644
--- a/libre/parabolaweb-utils/parabolaweb.service
+++ b/libre/parabolaweb-utils/parabolaweb.service
@@ -1,10 +1,13 @@
[Unit]
+Requires=postgresql.service
+After=postgresql.service
Description=ParabolaWeb
[Service]
Type=forking
-ExecStart=/usr/sbin/parabolaweb-fcgi pidfile=/run/web/parabolaweb.pid
PIDFile=/run/web/parabolaweb.pid
+ExecStartPre=/usr/bin/install -dm777 /run/web
+ExecStart=/usr/sbin/parabolaweb-fcgi pidfile=/run/web/parabolaweb.pid
[Install]
WantedBy=multi-user.target