Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Commit

Permalink
Update start-colab.sh to add plugins dynamically
Browse files Browse the repository at this point in the history
Signed-off-by: Matheus Fernandes <[email protected]>
  • Loading branch information
msfernandes committed Nov 9, 2017
1 parent ba83234 commit afb9e60
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ENV BUILD_PACKAGES python-dev python3 python3-dev linux-headers \

RUN apk add --update --no-cache $BUILD_PACKAGES
RUN mkdir -p /etc/colab /etc/colab/settings.d /etc/colab/plugins.d \
/etc/colab/widgets.d /var/labhacker/colab/public/media
/etc/colab/widgets.d /var/labhacker/colab/public/media \
/etc/cron.d/

ADD . /var/labhacker/colab
WORKDIR /var/labhacker/colab
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ services:
SITE_NAME: Câmara dos Deputados
SITE_LOGO: ''
SITE_BACKGROUND_IMAGE: ''
ENABLE_AUDIENCIAS: 'true'
ENABLE_WIKILEGIS: 'true'
AUDIENCIAS_API_KEY: secret_key
WIKILEGIS_API_KEY: api_key
volumes:
Expand Down
7 changes: 0 additions & 7 deletions misc/etc/cron.d/colab

This file was deleted.

1 change: 1 addition & 0 deletions misc/etc/cron.d/colab-audiencias
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * colab-admin fetch_data_audiencias
1 change: 1 addition & 0 deletions misc/etc/cron.d/colab-wikilegis
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/30 * * * * colab-admin fetch_data_wikilegis
32 changes: 28 additions & 4 deletions start-colab.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
#!/bin/bash

cp ./misc/etc/colab/plugins.d/audiencias.py /etc/colab/plugins.d/
cp ./misc/etc/colab/widgets.d/audiencias_widgets.py /etc/colab/widgets.d/
PLUGINS_SETTINGS="/etc/colab/plugins.d/"
if [ "$(ls -A $PLUGINS_SETTINGS)" ]; then
find $PLUGINS_SETTINGS ! -name 'edemocracia.py' -type f -exec rm -f {} +
fi

cp ./misc/etc/colab/plugins.d/wikilegis.py /etc/colab/plugins.d/
cp ./misc/etc/colab/widgets.d/wikilegis_widgets.py /etc/colab/widgets.d/
PLUGINS_WIDGETS="/etc/colab/widgets.d/"
if [ "$(ls -A $PLUGINS_WIDGETS)" ]; then
rm /etc/colab/widgets.d/*
fi

activate_plugin() {
PLUGIN_NAME=$1
cp ./misc/etc/colab/plugins.d/${PLUGIN_NAME}.py /etc/colab/plugins.d/
cp ./misc/etc/colab/widgets.d/${PLUGIN_NAME}_widgets.py /etc/colab/widgets.d/
cp ./misc/etc/cron.d/colab-${PLUGIN_NAME} /etc/cron.d/
crontab /etc/cron.d/colab-${PLUGIN_NAME}
}

[[ -z "${ENABLE_AUDIENCIAS}" ]] && ENABLE_AUDIENCIAS=2 || ENABLE_AUDIENCIAS="${ENABLE_AUDIENCIAS}"
[[ -z "${ENABLE_WIKILEGIS}" ]] && ENABLE_WIKILEGIS=2 || ENABLE_WIKILEGIS="${ENABLE_WIKILEGIS}"

if [[ "$ENABLE_WIKILEGIS" = true ]]; then
activate_plugin wikilegis
fi

if [[ "$ENABLE_AUDIENCIAS" = true ]]; then
activate_plugin audiencias
fi

crond
colab-admin migrate
colab-admin initdb
colab-admin compress --force
Expand Down

0 comments on commit afb9e60

Please sign in to comment.