diff --git a/precise/rsted/hooks/install b/precise/rsted/hooks/install new file mode 100755 index 0000000..308d869 --- /dev/null +++ b/precise/rsted/hooks/install @@ -0,0 +1,51 @@ +#!/bin/bash + + +RSTED_USER=${RSTED_USER:-rsted} +RSTED_GROUP=${RSTED_GROUP:-rsted} + +## +## Installation code +## + +source /srv/virtualenv/default/bin/activate +set -eux # -x for verbose logging to juju debug-log + + +mkdir -p /opt/apps +( + cd /opt/apps && + git clone https://github.com/anru/rsted.git && + adduser --system --home=/home/"$RSTED_USER" --group "$RSTED_GROUP" && + #chown "$RSTED_USER":"$RSTED_GROUP" /opt/apps/rsted -R && + ## -H is to force HOME environment variable to change to etherpad one. + cd rsted && + pip install -r pip-requirements.txt +) + + +## +## Config file +## + +config_file="/etc/rsted/settings.py" + +[ -e "$config_file" ] || cp "src/etc/rsted/settings.py" "$config_file" + +ln -sf "$config_file" /opt/apps/rsted/settings_local.py + + +## +## Startup file +## + +cp src/etc/init/rsted.conf /etc/init/rsted.conf + +## +## Logrotate +## + +cp src/etc/logrotate.d/rsted /etc/logrotate.d/rsted + + + diff --git a/precise/rsted/hooks/start b/precise/rsted/hooks/start new file mode 100755 index 0000000..9eb7853 --- /dev/null +++ b/precise/rsted/hooks/start @@ -0,0 +1,3 @@ +#!/bin/bash + +juju-log "Nothing to Start for base." diff --git a/precise/rsted/hooks/stop b/precise/rsted/hooks/stop new file mode 100755 index 0000000..170162b --- /dev/null +++ b/precise/rsted/hooks/stop @@ -0,0 +1,3 @@ +#!/bin/bash + +juju-log "Nothing to stop for base." diff --git a/precise/rsted/metadata.yaml b/precise/rsted/metadata.yaml new file mode 100644 index 0000000..58c44a9 --- /dev/null +++ b/precise/rsted/metadata.yaml @@ -0,0 +1,8 @@ +name: rsted +summary: "Rest server" +maintainer: "Valentin Lab " +inherit: python-venv +description: | + Restructured only editor +config-resources: + - /etc/rsted diff --git a/precise/rsted/revision b/precise/rsted/revision new file mode 100644 index 0000000..573541a --- /dev/null +++ b/precise/rsted/revision @@ -0,0 +1 @@ +0 diff --git a/precise/rsted/src/etc/init/rsted.conf b/precise/rsted/src/etc/init/rsted.conf new file mode 100644 index 0000000..3a2c222 --- /dev/null +++ b/precise/rsted/src/etc/init/rsted.conf @@ -0,0 +1,18 @@ +# Rsted upstart +# this script will start/stop Rsted +description "Rsted Server" +version "1.0" +author "Valentin Lab" + +start on started networking +stop on runlevel [!2345] + +env LOG_FILE=/var/log/rsted.log +env USER=rsted + + +script + chdir /opt/apps/rsted + exec sudo -u "$USER" /srv/virtualenv/default/bin/python ./application.py >> "$LOG_FILE" 2>&1 +end script + diff --git a/precise/rsted/src/etc/logrotate.d/rsted b/precise/rsted/src/etc/logrotate.d/rsted new file mode 100644 index 0000000..9d3e5cc --- /dev/null +++ b/precise/rsted/src/etc/logrotate.d/rsted @@ -0,0 +1,13 @@ +/var/log/rsted.log +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + restart rsted >/dev/null 2>&1 || true + endscript +} diff --git a/precise/rsted/src/etc/rsted/settings.py b/precise/rsted/src/etc/rsted/settings.py new file mode 100644 index 0000000..270b5ab --- /dev/null +++ b/precise/rsted/src/etc/rsted/settings.py @@ -0,0 +1,14 @@ +# configuration +DEBUG = True + +PYTHON_PATH='/srv/virtualenv/default/bin/python' +#RUN_AS='rsted' +RUN_PATH = '/var/run/rsted' +PID_FILE = 'fastcgi.pid' +SOCKET_FILE = 'rsted.sock' +FCGI_UMASK = '000' # you can override this in settings_local.py if you wish + +HOST = "0.0.0.0" ## Listen IP + ## 0.0.0.0 is open to everyone, + ## 127.0.0.1 is localhost only. +PORT = 5000