build
eggs
parts
-bin
sdist
develop-eggs
.installed.cfg
*.directory
var
-data/static
-data/mysql
-data/postgresql
-data/var
.thumbnails
.tmp
doc
+*.lock
# Installer logs
pip-log.txt
--- /dev/null
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py collectstatic --no-input
--- /dev/null
+#!/bin/bash
+
+export PGPASSWORD=$POSTGRES_PASSWORD
+
+pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/ircam-www.dump
+
+echo "Backup done!"
--- /dev/null
+#!/bin/bash
+
+pg_dump -hpgdb -Upostgres eve | gzip > /srv/backup/eve.sql.gz
--- /dev/null
+#!/bin/bash
+
+mysqldump -hdb -uroot -phyRob0otlaz4 ircam-www | gzip > /srv/backup/ircam-www.sql.gz
+echo "Backup done!"
--- /dev/null
+#!/bin/bash
+
+export PGPASSWORD=$POSTGRES_PASSWORD
+
+pg_restore -c -Fc -hdb -Upostgres -dpostgres /srv/backup/ircam-www.dump
+
+echo "Restore done!"
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/bash
+
+gunzip < /srv/backup/ircam_shops.sql.gz | mysql -hprestadb -uroot -pmysecretpassword ircam_shops
+echo "Restore done!"
--- /dev/null
+#!/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
--- /dev/null
+#!/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, user=None):
+ self.init_type = init_type
+ self.path = os.path.dirname(os.path.realpath(__file__))
+ self.config = config
+ self.config = os.path.abspath(self.get_root() + os.sep + self.config)
+ self.name = self.config.split(os.sep)[-2].lower()
+ self.cron = cron
+ if user:
+ self.user = user
+ else:
+ self.user = "root"
+
+ 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):
+ # version with migration
+ # without migration
+ log_path = "/var/log/"+ self.name
+ if not os.path.exists(log_path) :
+ os.makedirs(log_path, 0o755)
+ os.chown(log_path, getpwnam(self.user).pw_uid, getgrnam(self.user).gr_gid)
+ path = "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin\n"
+ command = "cd /srv/"+self.name+" && ./scripts/push.sh >> /var/log/"+ self.name +"/"+self.name+"-push.log 2>&1 \n"
+ rule = self.cron_rule % (self.user, command)
+ f = open('/etc/cron.d/' + self.name, 'w')
+ f.write(path + rule)
+ f.close()
+
+ 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('--user', help='specify user', type=str)
+ 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'], args['user'])
+ 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()
--- /dev/null
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py makemigrations $1
--- /dev/null
+#!/bin/sh
+
+docker-compose run app python /srv/app/manage.py migrate
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/sh
+
+sudo chown -R $USER var/media
+sudo chown -R $USER var/backup
+git pull
+git submodule foreach git pull
+docker-compose run db /srv/scripts/restore_db.sh
+gulp build
--- /dev/null
+#!/bin/bash
+
+echo "----------------------------"
+echo `date +\%Y\%m\%d-\%H-\%M-\%S`
+docker-compose run db /srv/scripts/backup_db.sh
+cd var
+git add .
+git commit -a -m "update DB and media"
+git pull origin master
+git push origin master
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/sh
+
+# Use this script to update a dev/prod server
+
+git pull
+git submodule foreach git pull origin master
+docker-compose run app python /srv/app/manage.py migrate
+# docker-compose run app python /srv/app/manage.py update_translation_fields
+bower install
+gulp build
+docker-compose run app python /srv/app/manage.py collectstatic --noinput
--- /dev/null
+deb http://mirrors.ircam.fr/pub/debian/ jessie main contrib non-free
+deb-src http://mirrors.ircam.fr/pub/debian/ testing main contrib non-free
+
+deb http://security.debian.org/ jessie/updates main
+deb-src http://security.debian.org/ jessie/updates main
+
+deb http://mirrors.ircam.fr/pub/debian/ jessie-updates main
+deb-src http://mirrors.ircam.fr/pub/debian/ jessie-updates main
--- /dev/null
+server_tokens off;
+
+server {
+ listen 80;
+ charset utf-8;
+
+ access_log /var/log/nginx/app-access.log;
+ error_log /var/log/nginx/app-error.log;
+
+ # max upload size
+ client_max_body_size 4096M; # adjust to taste
+
+ # Django media
+ location /media {
+ alias /srv/media; # your Django project's media files - amend as required
+ }
+ # Django static
+ location /static {
+ alias /srv/static; # your Django project's static files - amend as required
+ }
+
+ location / {
+ uwsgi_pass app:8000;
+ include /etc/nginx/uwsgi_params;
+ }
+}
+++ /dev/null
-deb http://mirrors.ircam.fr/pub/debian/ jessie main contrib non-free
-deb-src http://mirrors.ircam.fr/pub/debian/ testing main contrib non-free
-
-deb http://security.debian.org/ jessie/updates main
-deb-src http://security.debian.org/ jessie/updates main
-
-deb http://mirrors.ircam.fr/pub/debian/ jessie-updates main
-deb-src http://mirrors.ircam.fr/pub/debian/ jessie-updates main
+++ /dev/null
-#!/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, user=None):
- self.init_type = init_type
- self.path = os.path.dirname(os.path.realpath(__file__))
- self.config = config
- self.config = os.path.abspath(self.get_root() + os.sep + self.config)
- self.name = self.config.split(os.sep)[-2].lower()
- self.cron = cron
- if user:
- self.user = user
- else:
- self.user = "root"
-
- 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):
- # version with migration
- # without migration
- log_path = "/var/log/"+ self.name
- if not os.path.exists(log_path) :
- os.makedirs(log_path, 0o755)
- os.chown(log_path, getpwnam(self.user).pw_uid, getgrnam(self.user).gr_gid)
- path = "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin\n"
- command = "cd /srv/"+self.name+" && ./scripts/push.sh >> /var/log/"+ self.name +"/"+self.name+"-push.log 2>&1 \n"
- rule = self.cron_rule % (self.user, command)
- f = open('/etc/cron.d/' + self.name, 'w')
- f.write(path + rule)
- f.close()
-
- 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('--user', help='specify user', type=str)
- 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'], args['user'])
- 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()
+++ /dev/null
-#!/bin/bash
-
-export PGPASSWORD=$POSTGRES_PASSWORD
-
-pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/ircam-www.dump
-
-echo "Backup done!"
+++ /dev/null
-#!/bin/bash
-
-pg_dump -hpgdb -Upostgres eve | gzip > /srv/backup/eve.sql.gz
+++ /dev/null
-#!/bin/bash
-
-mysqldump -hdb -uroot -phyRob0otlaz4 ircam-www | gzip > /srv/backup/ircam-www.sql.gz
-echo "Backup done!"
+++ /dev/null
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py collectstatic --no-input
+++ /dev/null
-#!/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
-mkdir etc/nginx
-mkdir etc/nginx/conf.d/
-mv etc/nginx.conf etc/nginx/conf.d/default.conf
-mkdir etc/apt
-mv etc/sources.list etc/apt/
+++ /dev/null
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py makemigrations $1
+++ /dev/null
-#!/bin/sh
-
-docker-compose run app python /srv/app/manage.py migrate
+++ /dev/null
-#!/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
+++ /dev/null
-#!/bin/sh
-
-sudo chown -R $USER var/media
-sudo chown -R $USER var/backup
-git pull
-git submodule foreach git pull
-docker-compose run db /srv/scripts/restore_db.sh
-gulp build
+++ /dev/null
-#!/bin/bash
-
-echo "----------------------------"
-echo `date +\%Y\%m\%d-\%H-\%M-\%S`
-docker-compose run db /srv/scripts/backup_db.sh
-cd var
-git add .
-git commit -a -m "update DB and media"
-git pull origin master
-git push origin master
+++ /dev/null
-#!/bin/bash
-
-export PGPASSWORD=$POSTGRES_PASSWORD
-
-pg_restore -c -Fc -hdb -Upostgres -dpostgres /srv/backup/ircam-www.dump
-
-echo "Restore done!"
+++ /dev/null
-#!/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
+++ /dev/null
-#!/bin/bash
-
-gunzip < /srv/backup/ircam_shops.sql.gz | mysql -hprestadb -uroot -pmysecretpassword ircam_shops
-echo "Restore done!"
+++ /dev/null
-#!/bin/sh
-
-# Use this script to update a dev/prod server
-
-git pull
-git submodule foreach git pull origin master
-docker-compose run app python /srv/app/manage.py migrate
-# docker-compose run app python /srv/app/manage.py update_translation_fields
-bower install
-gulp build
-docker-compose run app python /srv/app/manage.py collectstatic --noinput