Commit dbaac292 authored by Tom Niget's avatar Tom Niget

add SQL init script

parent d4b209ad
......@@ -19,7 +19,7 @@ md5sum = bccd8d99888c3d4997443cae911eca79
[template-default]
_update_hash_filename_ = instance-default.cfg.in
md5sum = 5b843d5a0bb4f78936e51f3905bf482c
md5sum = 3934440228f4ce4495f3f2736db0e71d
[dovecot.jinja2.conf]
_update_hash_filename_ = dovecot.jinja2.conf
......
......@@ -252,6 +252,23 @@ output = ${directory:bin}/${:_buildout_section_name_}
inline =
#!/bin/sh
rm -f var/spool/postfix/pid/master.pid
'${postgresql-psql:wrapper-path}' \
-h '${postgresql:pgdata-directory}' \
-U '${postgresql:superuser}' \
-d '${postgresql:dbname}' \
-c "CREATE TABLE addresses (
email VARCHAR(50) NOT NULL PRIMARY KEY,
active BOOL NOT NULL DEFAULT TRUE,
passwd VARCHAR(106) NOT NULL
);
CREATE TABLE aliases (
source VARCHAR(50) NOT NULL PRIMARY KEY,
target VARCHAR(50) NOT NULL
);
INSERT INTO addresses (email, active, passwd) VALUES ('tom@mail.localhost', TRUE, 'MotDePasseEmail') ON CONFLICT(email) DO NOTHING;
INSERT INTO aliases (source, target) VALUES ('tniget@mail.localhost', 'tom@mail.localhost') ON CONFLICT(source) DO NOTHING;"
${directory:usr-postfix}/libexec/postfix/master -c ${directory:etc-postfix}
......@@ -503,6 +520,7 @@ extends =
parts =
directory
lamp-frontend-promise
# postgres-postinstall
snappymail-conf
snappymail-domain
dovecot-conf
......@@ -597,3 +615,22 @@ extensions = jinja2.ext.do
recipe = slapos.cookbook:wrapper
wrapper-path = ${directory:bin}/php
command-line = ${instance-parameter:php-bin} -c ${php.ini-conf:output}
# unused, remove at a later point
[postgres-postinstall]
recipe = slapos.recipe.build
# Pour que ça se fasse après l'install de postgresql
# pas nécessaire si tu as déjà besoin d'une autre valeur
depends = ${postgresql:recipe}
install =
import subprocess
args = ('${postgresql-psql:wrapper-path}',
'-h', '${postgresql:pgdata-directory}',
'-U', '${postgresql:superuser}',
'-d', '${postgresql:dbname}',
'-c', 'CREATE TABLE IF NOT EXISTS truc (bidule BOOL NOT NULL);')
p = subprocess.Popen(args)
retcode = p.poll()
if retcode:
raise subprocess.CalledProcessError(retcode, ' '.join(args))
open(options['location'], 'w').close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment