]> git.parisson.com Git - mezzo.git/commitdiff
Add bin as submodule, prepare lib as global lib directory
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 6 Jul 2017 16:32:21 +0000 (18:32 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 6 Jul 2017 16:32:57 +0000 (18:32 +0200)
58 files changed:
.gitignore
.gitmodules
Dockerfile
app/requirements.txt [new file with mode: 0644]
app/routers.py [deleted file]
bin [new submodule]
bin/build_doc.sh [deleted file]
bin/build_front.sh [deleted file]
bin/build_graph.sh [deleted file]
bin/build_messages.sh [deleted file]
bin/build_readme.sh [deleted file]
bin/collectstatic.sh [deleted file]
bin/db/backup.sh [deleted file]
bin/db/backup_db_eve.sh [deleted file]
bin/db/backup_db_mysql.sh [deleted file]
bin/db/restore.sh [deleted file]
bin/db/restore_db_eve.sh [deleted file]
bin/db/restore_db_mysql.sh [deleted file]
bin/docker-build.sh [deleted file]
bin/install.py [deleted file]
bin/makemigrations.sh [deleted file]
bin/migrate.sh [deleted file]
bin/pf_osx.sh [deleted file]
bin/poll_twitter.sh [deleted file]
bin/pull.sh [deleted file]
bin/push.sh [deleted file]
bin/tmp/fs_migrate.sh [deleted file]
bin/update_translation_fields.sh [deleted file]
bin/upgrade.sh [deleted file]
docker-compose.yml
env/dev.yml
env/lib.yml [deleted file]
requirements-debian.txt [deleted file]
requirements-python.txt [deleted file]
requirements.txt [new file with mode: 0644]
tmp/bin/build_doc.sh [new file with mode: 0755]
tmp/bin/build_front.sh [new file with mode: 0755]
tmp/bin/build_graph.sh [new file with mode: 0755]
tmp/bin/build_messages.sh [new file with mode: 0755]
tmp/bin/build_readme.sh [new file with mode: 0755]
tmp/bin/collectstatic.sh [new file with mode: 0755]
tmp/bin/db/backup.sh [new file with mode: 0755]
tmp/bin/db/backup_db_eve.sh [new file with mode: 0755]
tmp/bin/db/backup_db_mysql.sh [new file with mode: 0755]
tmp/bin/db/restore.sh [new file with mode: 0755]
tmp/bin/db/restore_db_eve.sh [new file with mode: 0755]
tmp/bin/db/restore_db_mysql.sh [new file with mode: 0755]
tmp/bin/docker-build.sh [new file with mode: 0755]
tmp/bin/install.py [new file with mode: 0755]
tmp/bin/makemigrations.sh [new file with mode: 0755]
tmp/bin/migrate.sh [new file with mode: 0755]
tmp/bin/pf_osx.sh [new file with mode: 0755]
tmp/bin/poll_twitter.sh [new file with mode: 0755]
tmp/bin/pull.sh [new file with mode: 0755]
tmp/bin/push.sh [new file with mode: 0755]
tmp/bin/tmp/fs_migrate.sh [new file with mode: 0755]
tmp/bin/update_translation_fields.sh [new file with mode: 0755]
tmp/bin/upgrade.sh [new file with mode: 0755]

index 3f3530c63010f30f40ec563889b6d6e8ac706657..c10e0be313913580970f17261d7964428d2828b8 100644 (file)
@@ -19,6 +19,7 @@ develop-eggs
 data
 postgres
 mysql
+tmp
 
 # Installer logs
 pip-log.txt
index 3866dac3c5358ee1903fc27032aa5db2ea4be3be..ad5be2c1c3d7eb3be20216b9992118e12e258b24 100644 (file)
@@ -1,12 +1,19 @@
-[submodule "lib/mezzanine-agenda"]
-       path = lib/mezzanine-agenda
-       url = https://github.com/yomguy/mezzanine-agenda.git
 [submodule "lib/mezzanine"]
        path = lib/mezzanine
        url = https://github.com/yomguy/mezzanine.git
+       branch = jquery
+[submodule "lib/mezzanine-agenda"]
+       path = lib/mezzanine-agenda
+       url = https://github.com/yomguy/mezzanine-agenda.git
+       branch = master
 [submodule "lib/mezzanine-organization"]
        path = lib/mezzanine-organization
        url = https://github.com/Ircam-Web/mezzanine-organization.git
+       branch = split
 [submodule "lib/mezzanine-organization-themes"]
        path = lib/mezzanine-organization-themes
        url = https://github.com/Ircam-Web/mezzanine-organization-themes.git
+       branch = master
+[submodule "bin"]
+       path = bin
+       url = https://github.com/Ircam-Web/mezzo-bin.git
index 6533730d29bea4a3d8fae277555e7888a4a4ad55..e232b3194c121ba64a3df5121067a1bc7142f20f 100644 (file)
@@ -8,9 +8,9 @@ WORKDIR /srv
 
 RUN apt-get update && apt-get install -y apt-transport-https
 COPY etc/apt/sources.list /etc/apt/
-COPY requirements-debian.txt /srv
+COPY requirements.txt /srv
 RUN apt-get update && \
-    DEBIAN_PACKAGES=$(egrep -v "^\s*(#|$)" /srv/requirements-debian.txt) && \
+    DEBIAN_PACKAGES=$(egrep -v "^\s*(#|$)" /srv/requirements.txt) && \
     apt-get install -y --force-yes $DEBIAN_PACKAGES && \
     echo fr_FR.UTF-8 UTF-8 >> /etc/locale.gen && \
     locale-gen && \
@@ -20,16 +20,20 @@ ENV LANG fr_FR.UTF-8
 ENV LANGUAGE fr_FR:fr
 ENV LC_ALL fr_FR.UTF-8
 
-COPY package.json /srv
+COPY lib/mezzanine-organization-themes/package.json /srv
 RUN npm install
 RUN npm install -g gulp
 RUN npm install -g bower
 
-COPY Gemfile /srv
+COPY lib/mezzanine-organization-themes/Gemfile /srv
 RUN gem install bundler
 RUN bundle install
 
-COPY requirements-python.txt /srv
-RUN pip install -r requirements-python.txt --src /srv/lib
+COPY app/requirements.txt /srv/app
+RUN pip install -r app/requirements.txt
+
+COPY lib /srv
+COPY bin/setup_lib.sh /srv
+RUN setup_lib.sh
 
 WORKDIR /srv/app
diff --git a/app/requirements.txt b/app/requirements.txt
new file mode 100644 (file)
index 0000000..7efbc04
--- /dev/null
@@ -0,0 +1,7 @@
+setuptools
+uwsgi
+mysqlclient
+psycopg2
+
+-e git+https://github.com/yomguy/grappelli-safe.git@dynamic_stacked#egg=grappelli-safe-0.4.2
+-e git+https://github.com/yomguy/cartridge.git#egg=cartridge-0.12-dev
diff --git a/app/routers.py b/app/routers.py
deleted file mode 100644 (file)
index cef15f8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2016-2017 Ircam
-# Copyright (c) 2016-2017 Guillaume Pellerin
-# Copyright (c) 2016-2017 Emilie Zawadzki
-
-# This file is part of mezzanine-organization.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-
-class Router(object):
-    """
-    A router to control all database operations between the 2 apps
-    """
-    def db_for_read(self, model, **hints):
-        if model._meta.app_label == 'eve':
-            return 'eve'
-        if model._meta.app_label == 'presta':
-            return 'presta'
-        return None
-
-    def db_for_write(self, model, **hints):
-        if model._meta.app_label == 'eve':
-            return 'eve'
-        if model._meta.app_label == 'presta':
-            return 'presta'
-        return None
-
-    def allow_relation(self, obj1, obj2, **hints):
-        if obj1._meta.app_label == 'eve' or \
-           obj2._meta.app_label == 'eve':
-           return True
-        if obj1._meta.app_label == 'presta' or \
-           obj2._meta.app_label == 'presta':
-           return True
-        return None
-
-    def allow_migrate(self, db, app_label, model=None, **hints):
-        if app_label == 'eve':
-            return db == 'eve'
-        if app_label == 'presta':
-            return db == 'presta'
-        return None
diff --git a/bin b/bin
new file mode 160000 (submodule)
index 0000000..1e524ee
--- /dev/null
+++ b/bin
@@ -0,0 +1 @@
+Subproject commit 1e524ee43dba281f6f04304f435df6c61e0e4d1b
diff --git a/bin/build_doc.sh b/bin/build_doc.sh
deleted file mode 100755 (executable)
index abc248d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app bash /srv/doc/build.sh
diff --git a/bin/build_front.sh b/bin/build_front.sh
deleted file mode 100755 (executable)
index 37cae07..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py build_themes --no-input
-docker-compose run app python /srv/app/manage.py collectstatic --no-input
diff --git a/bin/build_graph.sh b/bin/build_graph.sh
deleted file mode 100755 (executable)
index b5cda09..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py graph_models organization-core organization-media organization-pages organization.network organization.magazine organization.projects organization.agenda organization.shop organization.job > /srv/doc/graph/mezzanine-organization.dot
diff --git a/bin/build_messages.sh b/bin/build_messages.sh
deleted file mode 100755 (executable)
index 822e254..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python manage.py makemessages -a
-docker-compose run app python manage.py compilemessages
diff --git a/bin/build_readme.sh b/bin/build_readme.sh
deleted file mode 100755 (executable)
index b73a032..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cat doc/src/overview.rst doc/src/architecture.rst doc/src/install.rst doc/src/development.rst doc/src/maintenance.rst doc/src/copyright.rst doc/src/license.rst > README.rst
-echo "Build finished. The README.rst file is up to date."
diff --git a/bin/collectstatic.sh b/bin/collectstatic.sh
deleted file mode 100755 (executable)
index 611b171..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py collectstatic --no-input
diff --git a/bin/db/backup.sh b/bin/db/backup.sh
deleted file mode 100755 (executable)
index 300a3d8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-export PGPASSWORD=$POSTGRES_PASSWORD
-
-pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/postgres.dump
-
-echo "Backup done!"
diff --git a/bin/db/backup_db_eve.sh b/bin/db/backup_db_eve.sh
deleted file mode 100755 (executable)
index 888a3c2..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-pg_dump -hpgdb -Upostgres eve | gzip > /srv/backup/eve.sql.gz
diff --git a/bin/db/backup_db_mysql.sh b/bin/db/backup_db_mysql.sh
deleted file mode 100755 (executable)
index 43b57a3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-mysqldump -hdb -uroot -phyRob0otlaz4 ircam-www | gzip > /srv/backup/ircam-www.sql.gz
-echo "Backup done!"
diff --git a/bin/db/restore.sh b/bin/db/restore.sh
deleted file mode 100755 (executable)
index c084a16..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-export PGPASSWORD=$POSTGRES_PASSWORD
-
-pg_restore -c -Fc -hdb -Upostgres -dpostgres /srv/backup/postgres.dump
-
-echo "Restore done!"
diff --git a/bin/db/restore_db_eve.sh b/bin/db/restore_db_eve.sh
deleted file mode 100755 (executable)
index 91ba7b6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-export PGPASSWORD="q2nqzt0WGnwWé,256"
-
-db_exists=`psql -hevedb -Ueve -lqt  | cut -d \| -f 1 | grep -w eve | wc -l`
-
-#if [ ! $db_exists == 0 ]; then
-#    psql -hpgdb -Ueve  -c 'drop database eve'
-#fi
-
-psql -hevedb -Ueve -c 'create role eve'
-psql -hevedb -Ueve -c 'create role django'
-#psql -hevedb -Ueve -c 'create database eve'
-gunzip -c /srv/backup/eve.sql.gz | psql -hevedb -Ueve -q eve
diff --git a/bin/db/restore_db_mysql.sh b/bin/db/restore_db_mysql.sh
deleted file mode 100755 (executable)
index 26b338b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-gunzip < /srv/backup/ircam_shops.sql.gz | mysql -hprestadb -uroot -pmysecretpassword ircam_shops
-echo "Restore done!"
diff --git a/bin/docker-build.sh b/bin/docker-build.sh
deleted file mode 100755 (executable)
index bc536f4..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-# Always remove intermediate containers
-docker-compose build --force-rm
-# Delete all stopped containers (including data-only containers)
-docker rm $(docker ps -a -q)
-# Delete all 'untagged/dangling' (<none>) images
-docker rmi $(docker images -q -f dangling=true)
-# restart app container
-docker-compose restart app
diff --git a/bin/install.py b/bin/install.py
deleted file mode 100755 (executable)
index ba340c6..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/python
-"""
-The MIT License (MIT)
-Copyright (c) 2016 Guillaume Pellerin @yomguy
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-"""
-
-import os
-import argparse
-import platform
-from pwd import getpwnam
-from grp import getgrnam
-
-sysvinit_script = """#!/bin/sh
-### BEGIN INIT INFO
-# Provides:        %s
-# Required-Start:      docker
-# Required-Stop:       docker
-# Default-Start:       2 3 4 5
-# Default-Stop:                0 1 6
-# Short-Description:   Docker Services
-### END INIT INFO
-
-set -e
-
-PROJECT_NAME=%s
-YAMLFILE=%s
-OPTS="-f $YAMLFILE -p $PROJECT_NAME"
-UPOPTS="-d --no-recreate --no-build --no-deps"
-
-. /lib/lsb/init-functions
-
-case "$1" in
-    start)
-        log_daemon_msg "Starting $PROJECT_NAME composition" "$PROJECT_NAME" || true
-        if su -c "docker-compose $OPTS up $UPOPTS > /dev/null 2>&1" root ; then
-            log_end_msg 0 || true
-        else
-            log_end_msg 1 || true
-        fi
-        ;;
-
-    stop)
-        log_daemon_msg "Stopping $PROJECT_NAME composition" "$PROJECT_NAME" || true
-        if su -c "docker-compose $OPTS stop > /dev/null 2>&1" root; then
-            log_end_msg 0 || true
-        else
-            log_end_msg 1 || true
-        fi
-        ;;
-
-    reload|force-reload)
-        log_daemon_msg "Reloading $PROJECT_NAME composition" "$PROJECT_NAME" || true
-        if docker-compose $OPTS up $UPOPTS > /dev/null 2>&1 ; then
-            log_end_msg 0 || true
-        else
-            log_end_msg 1 || true
-        fi
-        ;;
-
-    restart|try-restart)
-        log_daemon_msg "Restarting $PROJECT_NAME composition" "$PROJECT_NAME" || true
-        if docker-compose $OPTS stop > /dev/null 2>&1; docker-compose $OPTS up $UPOPTS > /dev/null 2>&1 ; then
-            log_end_msg 0 || true
-        else
-            log_end_msg 1 || true
-        fi
-        ;;
-
-    status)
-        docker-compose $OPTS ps && exit 0 || exit $?
-        ;;
-
-    *)
-        log_action_msg "Usage: /etc/init.d/$PROJECT_NAME {start|stop|reload|force-reload|restart|try-restart|status}" || true
-        exit 1
-        ;;
-esac
-
-exit 0
-"""
-
-systemd_service = """
-[Unit]
-Description=%s composition
-Requires=docker.service
-After=docker.service
-ConditionPathExists=%s
-
-[Service]
-ExecStart=%s -f %s up -d
-ExecStop=%s -f %s stop
-
-[Install]
-WantedBy=local.target
-"""
-
-class DockerCompositionInstaller(object):
-
-    docker = '/etc/init.d/docker'
-    docker_compose = '/usr/local/bin/docker-compose'
-    cron_rule = "0 */6 * * * %s %s"
-
-    def __init__(self, config='docker-compose.yml', init_type='sysvinit', cron=False):
-        self.init_type = init_type
-        self.path = os.path.dirname(os.path.realpath(__file__))
-        self.config = config
-        self.root = self.get_root()
-        self.config = os.path.abspath(self.root + os.sep + self.config)
-        self.name = self.config.split(os.sep)[-2].lower()
-        self.cron = cron
-
-    def get_root(self):
-        path = self.path
-        while not self.config in os.listdir(path):
-            path = os.sep.join(path.split(os.sep)[:-1])
-            if not path:
-                raise ValueError('The YAML docker composition was not found, please type "install.py -h" for more infos.')
-        return path
-
-    def install_docker(self):
-        if not os.path.exists(self.docker):
-            print 'Installing docker first...'
-            os.system('wget -qO- https://get.docker.com/ | sh')
-        if not os.path.exists(self.docker_compose):
-            print 'Installing docker-compose...'
-            os.system('pip install docker-compose')
-
-    def install_daemon_sysvinit(self):
-        script = '/etc/init.d/' + self.name
-        print 'Writing sysvinit script in ' + script
-        data = sysvinit_script % (self.name, self.name, self.config)
-        f = open(script, 'w')
-        f.write(data)
-        f.close()
-        os.system('chmod 755 ' + script)
-        os.system('update-rc.d ' + self.name + ' defaults')
-
-    def install_daemon_systemd(self):
-        service = '/lib/systemd/system/' + self.name + '.service'
-        print 'Writing systemd service in ' +  service
-        data = systemd_service % (self.name, self.config, self.docker_compose,
-            self.config, self.docker_compose, self.config)
-        f = open(service, 'w')
-        f.write(data)
-        f.close()
-        os.system('systemctl enable ' + service)
-        os.system('systemctl daemon-reload')
-
-    def install_cron(self):
-        cron_path = os.sep.join([self.root, 'etc', 'cron.d', 'app'])
-        log_path = os.sep.join([self.root, 'var', 'log', 'cron'])
-        if not os.path.exists(log_path) :
-            os.makedirs(log_path, 0o755)
-        os.symlink(cron_path, '/etc/cron.d/' + self.name)
-
-    def uninstall_daemon_sysvinit(self):
-        script = '/etc/init.d/' + self.name
-        os.system('update-rc.d -f ' + self.name + ' remove')
-        os.system('rm ' + script)
-
-    def uninstall_daemon_systemd(self):
-        service = '/lib/systemd/system/' + self.name + '.service'
-        os.system('systemctl disable ' + service)
-        os.system('systemctl daemon-reload')
-        os.system('rm ' + service)
-
-    def uninstall_cron(self):
-        os.system('rm /etc/cron.d/' + self.name)
-
-    def uninstall(self):
-        print 'Uninstalling ' + self.name + ' composition as a daemon...'
-        if self.init_type == 'sysvinit':
-            self.uninstall_daemon_sysvinit()
-        elif self.init_type == 'systemd':
-            self.uninstall_daemon_systemd()
-        if self.cron:
-            self.uninstall_cron()
-        print 'Done'
-
-    def install(self):
-        print 'Installing ' + self.name + ' composition as a daemon...'
-        self.install_docker()
-        if self.init_type == 'sysvinit':
-            self.install_daemon_sysvinit()
-        elif self.init_type == 'systemd':
-            self.install_daemon_systemd()
-        if self.cron:
-            self.install_cron()
-        print 'Done'
-
-
-def main():
-    description ="""Install this docker composition program as a daemon with boot init (sysvinit by default)."""
-    parser = argparse.ArgumentParser(description=description)
-    parser.add_argument('--uninstall', help='uninstall the daemon', action='store_true')
-    parser.add_argument('--cron', help='install cron backup rule', action='store_true')
-    parser.add_argument('--systemd', help='use systemd', action='store_true')
-    parser.add_argument('composition_file', nargs='?', help='the path of the YAML composition file to use (optional)')
-
-    config = 'docker-compose.yml'
-    init_type = 'sysvinit'
-    args = vars(parser.parse_args())
-
-    if args['systemd']:
-        init_type = 'systemd'
-    if args['composition_file']:
-        config = args['composition_file']
-
-    installer = DockerCompositionInstaller(config, init_type, args['cron'])
-    if args['uninstall']:
-        installer.uninstall()
-    else:
-        installer.install()
-
-if __name__ == '__main__':
-    if not 'Linux' in platform.system():
-        print 'Sorry, this script in only compatible with Linux for the moment...\n'
-    else:
-        main()
diff --git a/bin/makemigrations.sh b/bin/makemigrations.sh
deleted file mode 100755 (executable)
index cc9ec66..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py makemigrations $1
diff --git a/bin/migrate.sh b/bin/migrate.sh
deleted file mode 100755 (executable)
index b561bbf..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py migrate
diff --git a/bin/pf_osx.sh b/bin/pf_osx.sh
deleted file mode 100755 (executable)
index 0d81e91..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash
-
-readonly PROGNAME=$(basename $0)
-
-port="${1}"
-foreground="false"
-stop="false"
-environment="default"
-quite="false"
-hostport="$1"
-
-usage="${PROGNAME} <port> [-h] [-s] [-f] [-e] [-hp] -- Forwards a docker-machine port so that you can access it locally
-
-where:
-    -h, --help         Show this help text
-    -s, --stop                 Stop the port forwarding process
-    -f, --foreground   Run the docker-machine ssh client in foreground instead of background
-    -e, --environment  The name of the docker-machine environment (default is default)
-    -q, --quite                Don't print anything to the console, not even errors    
-
-examples:
-       # Port forward port 8047 in docker-machine environment default
-       \$ ${PROGNAME} 8047
-
-       # Port forward docker port 8047 to host port 8087 in docker-machine environment default
-       \$ ${PROGNAME} 8087:8047
-
-       # Port forward port 8047 in docker-machine dev
-       \$ ${PROGNAME} 8047 -e dev
-
-       # Runs in foreground (port forwarding is automatically stopped when process is terminated)
-       \$ ${PROGNAME} 8047 -f
-
-       # Stop the port forwarding for this port
-       \$ ${PROGNAME} 8047 -s"
-
-if [ $# -eq 0 ]; then
-       echo "$usage"
-       exit 1
-fi
-
-if [ -z "$1" ]; then
-    echo "You need to specify the port to forward" >&2
-    echo "$usage"
-    exit 1
-fi
-
-if [ "$#" -ne 0 ]; then
-    while [ "$#" -gt 0 ]
-    do
-               case "$1" in
-               -h|--help)
-                       echo "$usage"
-                       exit 0
-                       ;;
-               -f|--foreground)
-                       foreground="true"
-                       ;;              
-        -s|--stop)
-            stop="true"
-            ;;
-        -e|--environment)
-            environment="$2"
-            ;;
-        -q|--quite)
-            quite="true"
-            ;;
-               --)
-                       break
-                       ;;
-               -*)
-                       echo "Invalid option '$1'. Use --help to see the valid options" >&2
-                       exit 1
-                       ;;
-               # an option argument, continue
-               *)  ;;
-               esac
-               shift
-    done
-fi
-
-pidport() {
-       lsof -n -i4TCP:$1 | grep --exclude-dir={.bzr,CVS,.git,.hg,.svn} LISTEN
-}
-
-# Check if port contains ":", if so we should split
-if [[ $port == *":"* ]]; then  
-       # Split by :
-       ports=(${port//:/ })
-       if [[ ${#ports[@]} != 2 ]]; then
-               if [[ $quite == "false" ]]; then 
-                       echo "Port forwarding should be defined as hostport:targetport, for example: 8090:8080"
-               fi
-               exit 1
-       fi
-
-
-       hostport=${ports[0]}
-       port=${ports[1]}
-fi
-
-
-if [[ ${stop} == "true" ]]; then
-       result=`pidport $hostport`
-
-       if [ -z "${result}"  ]; then
-               if [[ $quite == "false" ]]; then
-                       echo "Port $hostport is not forwarded, cannot stop"
-               fi              
-               exit 1
-       fi 
-
-       process=`echo "${result}" | awk '{ print $1 }'`
-       if [[ $process != "ssh" ]]; then
-               if [[ $quite == "false" ]]; then 
-                       echo "Port $hostport is bound by process ${process} and not by docker-machine, won't stop"
-               fi
-               exit 1
-       fi
-
-       pid=`echo "${result}" | awk '{ print $2 }'` &&
-       kill $pid &&
-       echo "Stopped port forwarding for $hostport"            
-else
-       docker-machine ssh $environment `if [[ ${foreground} == "false" ]]; then echo "-f -N"; fi` -L $hostport:localhost:$port && 
-       if [[ $quite == "false" ]] && [[ $foreground == "false" ]]; then
-               printf "Forwarding port $port"
-               if [[ $hostport -ne $port ]]; then
-                       printf " to host port $hostport"
-               fi
-               echo " in docker-machine environment $environment."
-       fi
-fi
diff --git a/bin/poll_twitter.sh b/bin/poll_twitter.sh
deleted file mode 100755 (executable)
index cfa0d03..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py poll_twitter --force
diff --git a/bin/pull.sh b/bin/pull.sh
deleted file mode 100755 (executable)
index a3d67ab..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-sudo chown -R $USER var/media
-sudo chown -R $USER var/backup
-git pull
-git submodule foreach git pull origin master
-docker-compose run db /srv/bin/db/restore.sh
-docker-compose run app bash -c "cd /srv && bower --allow-root install && gulp build"
diff --git a/bin/push.sh b/bin/push.sh
deleted file mode 100755 (executable)
index 198e2d5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-echo "----------------------------"
-echo `date +\%Y\%m\%d-\%H-\%M-\%S`
-docker-compose run db /srv/bin/db/backup.sh
-cd var
-git add .
-git commit -a -m "update DB and media"
-git pull
-git push
diff --git a/bin/tmp/fs_migrate.sh b/bin/tmp/fs_migrate.sh
deleted file mode 100755 (executable)
index 9ec9fcf..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-docker-compose stop
-mv data var
-mkdir var/lib
-sudo mv var/postgresql var/lib
-sudo mv var/external var/opt
-sudo mv var/var/log var
-sudo rm -rf var/var
diff --git a/bin/update_translation_fields.sh b/bin/update_translation_fields.sh
deleted file mode 100755 (executable)
index 55bec14..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py update_translation_fields
diff --git a/bin/upgrade.sh b/bin/upgrade.sh
deleted file mode 100755 (executable)
index 308af71..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-git pull
-git submodule foreach git pull
-docker-compose run app python /srv/app/manage.py migrate
-# docker-compose run app python /srv/app/manage.py update_translation_fields
-docker-compose run app bash -c "cd /srv && bower --allow-root install && gulp build"
-docker-compose run app python /srv/app/manage.py collectstatic --noinput
-docker-compose run app bash /srv/doc/build.sh
-touch app/wsgi.py
index 36a2ccdc8a00eb602dda50a127e1a5bbab781129..4646b16c58aae6d6c5a0f0b1597e2e5f7f01516b 100644 (file)
@@ -43,30 +43,18 @@ db:
 
 app:
   build: .
-  command: /bin/bash bin/app.sh
+  command: /bin/sh bin/app.sh --runserver
   volumes:
     - ./app:/srv/app
-    - ./lib/mezzanine/:/srv/lib/mezzanine
-    - ./lib/mezzanine-agenda:/srv/lib/mezzanine-agenda
-    - ./lib/mezzanine-organization:/srv/lib/mezzanine-organization
-    - ./lib/mezzanine-organization-themes:/srv/lib/mezzanine-organization-themes
+    - ./lib/:/srv/lib/
+    
   volumes_from:
     - var
   expose:
     - "8000"
+  ports:
+    - "9022:8000"
   links:
     - db
   environment:
-   - DEBUG=False
-
-nginx:
-  image: nginx
-  ports:
-    - "8022:80"
-  volumes:
-    - ./etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
-    - ./etc/nginx/htpasswd:/etc/nginx/htpasswd
-  volumes_from:
-    - var
-  links:
-    - app
+    - DEBUG=True
index 01ec3572a291a14b52fc90330c4f3ecacc3664c5..58658d2e384501297b32632bac5698ba689192d8 100644 (file)
@@ -1,23 +1,3 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2015 Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-# Manifeste is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# Manifeste is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Manifeste.  If not, see <http://www.gnu.org/licenses/>.
-
-# Authors:
-# Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
 
 app:
   command: /bin/sh bin/app.sh --runserver
diff --git a/env/lib.yml b/env/lib.yml
deleted file mode 100644 (file)
index 839cb24..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2015 Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-# Manifeste is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# Manifeste is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Manifeste.  If not, see <http://www.gnu.org/licenses/>.
-
-# Authors:
-# Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-
-app:
-  volumes:
-    - ./app/:/srv/app
-    - ./lib/mezzanine-agenda/:/srv/lib/mezzanine-agenda
diff --git a/requirements-debian.txt b/requirements-debian.txt
deleted file mode 100644 (file)
index 621b42c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-git
-wget
-bzip2
-build-essential
-netcat
-nodejs
-locales
-pandoc
-vim
-python-sphinx
-ruby
-ruby-dev
-gettext
diff --git a/requirements-python.txt b/requirements-python.txt
deleted file mode 100644 (file)
index 1143dac..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-setuptools
-uwsgi
-watchdog
-mysqlclient
-psycopg2
-django==1.9.11
-
--e git+https://github.com/yomguy/mezzanine.git@jquery#egg=mezzanine-4.2-dev
--e git+https://github.com/yomguy/grappelli-safe.git@dynamic_stacked#egg=grappelli-safe-0.4.2
--e git+https://github.com/yomguy/cartridge.git#egg=cartridge-0.12-dev
--e git+https://github.com/yomguy/mezzanine-agenda.git#egg=mezzanine-agenda-0.2.2
--e git+https://github.com/Ircam-Web/mezzanine-organization.git@split#egg=mezzanine-organization-1.0
--e git+https://github.com/Ircam-Web/mezzanine-organization-themes.git#egg=mezzanine-organization-themes-1.0
diff --git a/requirements.txt b/requirements.txt
new file mode 100644 (file)
index 0000000..3e1e873
--- /dev/null
@@ -0,0 +1,13 @@
+git
+wget
+bzip2
+build-essential
+netcat
+nodejs
+locales
+pandoc
+vim
+ruby
+ruby-dev
+gettext
+python-sphinx
diff --git a/tmp/bin/build_doc.sh b/tmp/bin/build_doc.sh
new file mode 100755 (executable)
index 0000000..abc248d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app bash /srv/doc/build.sh
diff --git a/tmp/bin/build_front.sh b/tmp/bin/build_front.sh
new file mode 100755 (executable)
index 0000000..37cae07
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py build_themes --no-input
+docker-compose run app python /srv/app/manage.py collectstatic --no-input
diff --git a/tmp/bin/build_graph.sh b/tmp/bin/build_graph.sh
new file mode 100755 (executable)
index 0000000..b5cda09
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py graph_models organization-core organization-media organization-pages organization.network organization.magazine organization.projects organization.agenda organization.shop organization.job > /srv/doc/graph/mezzanine-organization.dot
diff --git a/tmp/bin/build_messages.sh b/tmp/bin/build_messages.sh
new file mode 100755 (executable)
index 0000000..822e254
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+docker-compose run app python manage.py makemessages -a
+docker-compose run app python manage.py compilemessages
diff --git a/tmp/bin/build_readme.sh b/tmp/bin/build_readme.sh
new file mode 100755 (executable)
index 0000000..b73a032
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cat doc/src/overview.rst doc/src/architecture.rst doc/src/install.rst doc/src/development.rst doc/src/maintenance.rst doc/src/copyright.rst doc/src/license.rst > README.rst
+echo "Build finished. The README.rst file is up to date."
diff --git a/tmp/bin/collectstatic.sh b/tmp/bin/collectstatic.sh
new file mode 100755 (executable)
index 0000000..611b171
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py collectstatic --no-input
diff --git a/tmp/bin/db/backup.sh b/tmp/bin/db/backup.sh
new file mode 100755 (executable)
index 0000000..300a3d8
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export PGPASSWORD=$POSTGRES_PASSWORD
+
+pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/postgres.dump
+
+echo "Backup done!"
diff --git a/tmp/bin/db/backup_db_eve.sh b/tmp/bin/db/backup_db_eve.sh
new file mode 100755 (executable)
index 0000000..888a3c2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+pg_dump -hpgdb -Upostgres eve | gzip > /srv/backup/eve.sql.gz
diff --git a/tmp/bin/db/backup_db_mysql.sh b/tmp/bin/db/backup_db_mysql.sh
new file mode 100755 (executable)
index 0000000..43b57a3
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+mysqldump -hdb -uroot -phyRob0otlaz4 ircam-www | gzip > /srv/backup/ircam-www.sql.gz
+echo "Backup done!"
diff --git a/tmp/bin/db/restore.sh b/tmp/bin/db/restore.sh
new file mode 100755 (executable)
index 0000000..c084a16
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export PGPASSWORD=$POSTGRES_PASSWORD
+
+pg_restore -c -Fc -hdb -Upostgres -dpostgres /srv/backup/postgres.dump
+
+echo "Restore done!"
diff --git a/tmp/bin/db/restore_db_eve.sh b/tmp/bin/db/restore_db_eve.sh
new file mode 100755 (executable)
index 0000000..91ba7b6
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+export PGPASSWORD="q2nqzt0WGnwWé,256"
+
+db_exists=`psql -hevedb -Ueve -lqt  | cut -d \| -f 1 | grep -w eve | wc -l`
+
+#if [ ! $db_exists == 0 ]; then
+#    psql -hpgdb -Ueve  -c 'drop database eve'
+#fi
+
+psql -hevedb -Ueve -c 'create role eve'
+psql -hevedb -Ueve -c 'create role django'
+#psql -hevedb -Ueve -c 'create database eve'
+gunzip -c /srv/backup/eve.sql.gz | psql -hevedb -Ueve -q eve
diff --git a/tmp/bin/db/restore_db_mysql.sh b/tmp/bin/db/restore_db_mysql.sh
new file mode 100755 (executable)
index 0000000..26b338b
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+gunzip < /srv/backup/ircam_shops.sql.gz | mysql -hprestadb -uroot -pmysecretpassword ircam_shops
+echo "Restore done!"
diff --git a/tmp/bin/docker-build.sh b/tmp/bin/docker-build.sh
new file mode 100755 (executable)
index 0000000..bc536f4
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Always remove intermediate containers
+docker-compose build --force-rm
+# Delete all stopped containers (including data-only containers)
+docker rm $(docker ps -a -q)
+# Delete all 'untagged/dangling' (<none>) images
+docker rmi $(docker images -q -f dangling=true)
+# restart app container
+docker-compose restart app
diff --git a/tmp/bin/install.py b/tmp/bin/install.py
new file mode 100755 (executable)
index 0000000..ba340c6
--- /dev/null
@@ -0,0 +1,225 @@
+#!/usr/bin/python
+"""
+The MIT License (MIT)
+Copyright (c) 2016 Guillaume Pellerin @yomguy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+"""
+
+import os
+import argparse
+import platform
+from pwd import getpwnam
+from grp import getgrnam
+
+sysvinit_script = """#!/bin/sh
+### BEGIN INIT INFO
+# Provides:        %s
+# Required-Start:      docker
+# Required-Stop:       docker
+# Default-Start:       2 3 4 5
+# Default-Stop:                0 1 6
+# Short-Description:   Docker Services
+### END INIT INFO
+
+set -e
+
+PROJECT_NAME=%s
+YAMLFILE=%s
+OPTS="-f $YAMLFILE -p $PROJECT_NAME"
+UPOPTS="-d --no-recreate --no-build --no-deps"
+
+. /lib/lsb/init-functions
+
+case "$1" in
+    start)
+        log_daemon_msg "Starting $PROJECT_NAME composition" "$PROJECT_NAME" || true
+        if su -c "docker-compose $OPTS up $UPOPTS > /dev/null 2>&1" root ; then
+            log_end_msg 0 || true
+        else
+            log_end_msg 1 || true
+        fi
+        ;;
+
+    stop)
+        log_daemon_msg "Stopping $PROJECT_NAME composition" "$PROJECT_NAME" || true
+        if su -c "docker-compose $OPTS stop > /dev/null 2>&1" root; then
+            log_end_msg 0 || true
+        else
+            log_end_msg 1 || true
+        fi
+        ;;
+
+    reload|force-reload)
+        log_daemon_msg "Reloading $PROJECT_NAME composition" "$PROJECT_NAME" || true
+        if docker-compose $OPTS up $UPOPTS > /dev/null 2>&1 ; then
+            log_end_msg 0 || true
+        else
+            log_end_msg 1 || true
+        fi
+        ;;
+
+    restart|try-restart)
+        log_daemon_msg "Restarting $PROJECT_NAME composition" "$PROJECT_NAME" || true
+        if docker-compose $OPTS stop > /dev/null 2>&1; docker-compose $OPTS up $UPOPTS > /dev/null 2>&1 ; then
+            log_end_msg 0 || true
+        else
+            log_end_msg 1 || true
+        fi
+        ;;
+
+    status)
+        docker-compose $OPTS ps && exit 0 || exit $?
+        ;;
+
+    *)
+        log_action_msg "Usage: /etc/init.d/$PROJECT_NAME {start|stop|reload|force-reload|restart|try-restart|status}" || true
+        exit 1
+        ;;
+esac
+
+exit 0
+"""
+
+systemd_service = """
+[Unit]
+Description=%s composition
+Requires=docker.service
+After=docker.service
+ConditionPathExists=%s
+
+[Service]
+ExecStart=%s -f %s up -d
+ExecStop=%s -f %s stop
+
+[Install]
+WantedBy=local.target
+"""
+
+class DockerCompositionInstaller(object):
+
+    docker = '/etc/init.d/docker'
+    docker_compose = '/usr/local/bin/docker-compose'
+    cron_rule = "0 */6 * * * %s %s"
+
+    def __init__(self, config='docker-compose.yml', init_type='sysvinit', cron=False):
+        self.init_type = init_type
+        self.path = os.path.dirname(os.path.realpath(__file__))
+        self.config = config
+        self.root = self.get_root()
+        self.config = os.path.abspath(self.root + os.sep + self.config)
+        self.name = self.config.split(os.sep)[-2].lower()
+        self.cron = cron
+
+    def get_root(self):
+        path = self.path
+        while not self.config in os.listdir(path):
+            path = os.sep.join(path.split(os.sep)[:-1])
+            if not path:
+                raise ValueError('The YAML docker composition was not found, please type "install.py -h" for more infos.')
+        return path
+
+    def install_docker(self):
+        if not os.path.exists(self.docker):
+            print 'Installing docker first...'
+            os.system('wget -qO- https://get.docker.com/ | sh')
+        if not os.path.exists(self.docker_compose):
+            print 'Installing docker-compose...'
+            os.system('pip install docker-compose')
+
+    def install_daemon_sysvinit(self):
+        script = '/etc/init.d/' + self.name
+        print 'Writing sysvinit script in ' + script
+        data = sysvinit_script % (self.name, self.name, self.config)
+        f = open(script, 'w')
+        f.write(data)
+        f.close()
+        os.system('chmod 755 ' + script)
+        os.system('update-rc.d ' + self.name + ' defaults')
+
+    def install_daemon_systemd(self):
+        service = '/lib/systemd/system/' + self.name + '.service'
+        print 'Writing systemd service in ' +  service
+        data = systemd_service % (self.name, self.config, self.docker_compose,
+            self.config, self.docker_compose, self.config)
+        f = open(service, 'w')
+        f.write(data)
+        f.close()
+        os.system('systemctl enable ' + service)
+        os.system('systemctl daemon-reload')
+
+    def install_cron(self):
+        cron_path = os.sep.join([self.root, 'etc', 'cron.d', 'app'])
+        log_path = os.sep.join([self.root, 'var', 'log', 'cron'])
+        if not os.path.exists(log_path) :
+            os.makedirs(log_path, 0o755)
+        os.symlink(cron_path, '/etc/cron.d/' + self.name)
+
+    def uninstall_daemon_sysvinit(self):
+        script = '/etc/init.d/' + self.name
+        os.system('update-rc.d -f ' + self.name + ' remove')
+        os.system('rm ' + script)
+
+    def uninstall_daemon_systemd(self):
+        service = '/lib/systemd/system/' + self.name + '.service'
+        os.system('systemctl disable ' + service)
+        os.system('systemctl daemon-reload')
+        os.system('rm ' + service)
+
+    def uninstall_cron(self):
+        os.system('rm /etc/cron.d/' + self.name)
+
+    def uninstall(self):
+        print 'Uninstalling ' + self.name + ' composition as a daemon...'
+        if self.init_type == 'sysvinit':
+            self.uninstall_daemon_sysvinit()
+        elif self.init_type == 'systemd':
+            self.uninstall_daemon_systemd()
+        if self.cron:
+            self.uninstall_cron()
+        print 'Done'
+
+    def install(self):
+        print 'Installing ' + self.name + ' composition as a daemon...'
+        self.install_docker()
+        if self.init_type == 'sysvinit':
+            self.install_daemon_sysvinit()
+        elif self.init_type == 'systemd':
+            self.install_daemon_systemd()
+        if self.cron:
+            self.install_cron()
+        print 'Done'
+
+
+def main():
+    description ="""Install this docker composition program as a daemon with boot init (sysvinit by default)."""
+    parser = argparse.ArgumentParser(description=description)
+    parser.add_argument('--uninstall', help='uninstall the daemon', action='store_true')
+    parser.add_argument('--cron', help='install cron backup rule', action='store_true')
+    parser.add_argument('--systemd', help='use systemd', action='store_true')
+    parser.add_argument('composition_file', nargs='?', help='the path of the YAML composition file to use (optional)')
+
+    config = 'docker-compose.yml'
+    init_type = 'sysvinit'
+    args = vars(parser.parse_args())
+
+    if args['systemd']:
+        init_type = 'systemd'
+    if args['composition_file']:
+        config = args['composition_file']
+
+    installer = DockerCompositionInstaller(config, init_type, args['cron'])
+    if args['uninstall']:
+        installer.uninstall()
+    else:
+        installer.install()
+
+if __name__ == '__main__':
+    if not 'Linux' in platform.system():
+        print 'Sorry, this script in only compatible with Linux for the moment...\n'
+    else:
+        main()
diff --git a/tmp/bin/makemigrations.sh b/tmp/bin/makemigrations.sh
new file mode 100755 (executable)
index 0000000..cc9ec66
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py makemigrations $1
diff --git a/tmp/bin/migrate.sh b/tmp/bin/migrate.sh
new file mode 100755 (executable)
index 0000000..b561bbf
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py migrate
diff --git a/tmp/bin/pf_osx.sh b/tmp/bin/pf_osx.sh
new file mode 100755 (executable)
index 0000000..0d81e91
--- /dev/null
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+readonly PROGNAME=$(basename $0)
+
+port="${1}"
+foreground="false"
+stop="false"
+environment="default"
+quite="false"
+hostport="$1"
+
+usage="${PROGNAME} <port> [-h] [-s] [-f] [-e] [-hp] -- Forwards a docker-machine port so that you can access it locally
+
+where:
+    -h, --help         Show this help text
+    -s, --stop                 Stop the port forwarding process
+    -f, --foreground   Run the docker-machine ssh client in foreground instead of background
+    -e, --environment  The name of the docker-machine environment (default is default)
+    -q, --quite                Don't print anything to the console, not even errors    
+
+examples:
+       # Port forward port 8047 in docker-machine environment default
+       \$ ${PROGNAME} 8047
+
+       # Port forward docker port 8047 to host port 8087 in docker-machine environment default
+       \$ ${PROGNAME} 8087:8047
+
+       # Port forward port 8047 in docker-machine dev
+       \$ ${PROGNAME} 8047 -e dev
+
+       # Runs in foreground (port forwarding is automatically stopped when process is terminated)
+       \$ ${PROGNAME} 8047 -f
+
+       # Stop the port forwarding for this port
+       \$ ${PROGNAME} 8047 -s"
+
+if [ $# -eq 0 ]; then
+       echo "$usage"
+       exit 1
+fi
+
+if [ -z "$1" ]; then
+    echo "You need to specify the port to forward" >&2
+    echo "$usage"
+    exit 1
+fi
+
+if [ "$#" -ne 0 ]; then
+    while [ "$#" -gt 0 ]
+    do
+               case "$1" in
+               -h|--help)
+                       echo "$usage"
+                       exit 0
+                       ;;
+               -f|--foreground)
+                       foreground="true"
+                       ;;              
+        -s|--stop)
+            stop="true"
+            ;;
+        -e|--environment)
+            environment="$2"
+            ;;
+        -q|--quite)
+            quite="true"
+            ;;
+               --)
+                       break
+                       ;;
+               -*)
+                       echo "Invalid option '$1'. Use --help to see the valid options" >&2
+                       exit 1
+                       ;;
+               # an option argument, continue
+               *)  ;;
+               esac
+               shift
+    done
+fi
+
+pidport() {
+       lsof -n -i4TCP:$1 | grep --exclude-dir={.bzr,CVS,.git,.hg,.svn} LISTEN
+}
+
+# Check if port contains ":", if so we should split
+if [[ $port == *":"* ]]; then  
+       # Split by :
+       ports=(${port//:/ })
+       if [[ ${#ports[@]} != 2 ]]; then
+               if [[ $quite == "false" ]]; then 
+                       echo "Port forwarding should be defined as hostport:targetport, for example: 8090:8080"
+               fi
+               exit 1
+       fi
+
+
+       hostport=${ports[0]}
+       port=${ports[1]}
+fi
+
+
+if [[ ${stop} == "true" ]]; then
+       result=`pidport $hostport`
+
+       if [ -z "${result}"  ]; then
+               if [[ $quite == "false" ]]; then
+                       echo "Port $hostport is not forwarded, cannot stop"
+               fi              
+               exit 1
+       fi 
+
+       process=`echo "${result}" | awk '{ print $1 }'`
+       if [[ $process != "ssh" ]]; then
+               if [[ $quite == "false" ]]; then 
+                       echo "Port $hostport is bound by process ${process} and not by docker-machine, won't stop"
+               fi
+               exit 1
+       fi
+
+       pid=`echo "${result}" | awk '{ print $2 }'` &&
+       kill $pid &&
+       echo "Stopped port forwarding for $hostport"            
+else
+       docker-machine ssh $environment `if [[ ${foreground} == "false" ]]; then echo "-f -N"; fi` -L $hostport:localhost:$port && 
+       if [[ $quite == "false" ]] && [[ $foreground == "false" ]]; then
+               printf "Forwarding port $port"
+               if [[ $hostport -ne $port ]]; then
+                       printf " to host port $hostport"
+               fi
+               echo " in docker-machine environment $environment."
+       fi
+fi
diff --git a/tmp/bin/poll_twitter.sh b/tmp/bin/poll_twitter.sh
new file mode 100755 (executable)
index 0000000..cfa0d03
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py poll_twitter --force
diff --git a/tmp/bin/pull.sh b/tmp/bin/pull.sh
new file mode 100755 (executable)
index 0000000..a3d67ab
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+sudo chown -R $USER var/media
+sudo chown -R $USER var/backup
+git pull
+git submodule foreach git pull origin master
+docker-compose run db /srv/bin/db/restore.sh
+docker-compose run app bash -c "cd /srv && bower --allow-root install && gulp build"
diff --git a/tmp/bin/push.sh b/tmp/bin/push.sh
new file mode 100755 (executable)
index 0000000..198e2d5
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "----------------------------"
+echo `date +\%Y\%m\%d-\%H-\%M-\%S`
+docker-compose run db /srv/bin/db/backup.sh
+cd var
+git add .
+git commit -a -m "update DB and media"
+git pull
+git push
diff --git a/tmp/bin/tmp/fs_migrate.sh b/tmp/bin/tmp/fs_migrate.sh
new file mode 100755 (executable)
index 0000000..9ec9fcf
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+docker-compose stop
+mv data var
+mkdir var/lib
+sudo mv var/postgresql var/lib
+sudo mv var/external var/opt
+sudo mv var/var/log var
+sudo rm -rf var/var
diff --git a/tmp/bin/update_translation_fields.sh b/tmp/bin/update_translation_fields.sh
new file mode 100755 (executable)
index 0000000..55bec14
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py update_translation_fields
diff --git a/tmp/bin/upgrade.sh b/tmp/bin/upgrade.sh
new file mode 100755 (executable)
index 0000000..308af71
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+git pull
+git submodule foreach git pull
+docker-compose run app python /srv/app/manage.py migrate
+# docker-compose run app python /srv/app/manage.py update_translation_fields
+docker-compose run app bash -c "cd /srv && bower --allow-root install && gulp build"
+docker-compose run app python /srv/app/manage.py collectstatic --noinput
+docker-compose run app bash /srv/doc/build.sh
+touch app/wsgi.py