2014-10-28 15:10:30 +00:00
|
|
|
[Unit]
|
|
|
|
Description=%p-%i
|
2014-10-28 16:24:00 +00:00
|
|
|
|
|
|
|
# Requirements
|
2014-10-28 15:10:30 +00:00
|
|
|
Requires=docker.service
|
|
|
|
|
2014-10-28 16:24:00 +00:00
|
|
|
# Dependency ordering
|
|
|
|
After=docker.service
|
2014-12-03 17:08:01 +00:00
|
|
|
Before=backup@%i.timer
|
2014-10-28 16:24:00 +00:00
|
|
|
|
2015-01-12 09:18:35 +00:00
|
|
|
# Dependency binding
|
|
|
|
BindsTo=lamp@%i.service
|
|
|
|
|
2014-10-28 15:10:30 +00:00
|
|
|
[Service]
|
|
|
|
Restart=always
|
2015-01-15 16:37:11 +00:00
|
|
|
RestartSec=20
|
2015-01-16 10:01:44 +00:00
|
|
|
TimeoutStartSec=0
|
2015-01-12 13:36:48 +00:00
|
|
|
Type=notify
|
|
|
|
NotifyAccess=all
|
|
|
|
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
|
2014-10-28 16:24:00 +00:00
|
|
|
ExecStartPre=-/usr/bin/docker kill %p-%i
|
2014-10-28 15:10:30 +00:00
|
|
|
ExecStartPre=-/usr/bin/docker rm %p-%i
|
2015-01-11 19:04:01 +00:00
|
|
|
ExecStartPre=/bin/bash -euxc ' \
|
|
|
|
mysql_folder=/data/domains/%i/mysql; \
|
|
|
|
if [ ! -d /data/runtime/domains/%i/mysql ]; then \
|
2015-01-12 13:40:31 +00:00
|
|
|
mkdir -p /data/runtime/domains/%i/mysql/db_files; \
|
2015-01-11 19:04:01 +00:00
|
|
|
if [ ! -d $mysql_folder ]; then \
|
|
|
|
mkdir -p $mysql_folder; \
|
|
|
|
pass=`echo $RANDOM ${date} | md5sum | base64 | cut -c-10`; \
|
|
|
|
echo MYSQL_PASS=$pass > $mysql_folder/.env; \
|
|
|
|
fi; \
|
|
|
|
fi'
|
|
|
|
|
2015-01-12 13:36:48 +00:00
|
|
|
ExecStart=/opt/bin/systemd-docker run \
|
2015-01-14 13:48:24 +00:00
|
|
|
--rm \
|
2014-10-28 16:24:00 +00:00
|
|
|
--name %p-%i \
|
2015-02-16 16:33:03 +00:00
|
|
|
-v /data/runtime/domains/%i/log/mysql:/var/log/mysql \
|
2014-11-04 19:25:39 +00:00
|
|
|
-v /data/runtime/domains/%i/%p/db_files:/var/lib/mysql \
|
2014-11-04 18:07:18 +00:00
|
|
|
--env-file /data/domains/%i/%p/.env \
|
2015-01-05 16:35:46 +00:00
|
|
|
pierreozoux/mysql
|
2014-10-28 15:10:30 +00:00
|
|
|
ExecReload=/usr/bin/docker restart %p-%i
|
2014-10-28 16:24:00 +00:00
|
|
|
ExecStop=/usr/bin/docker stop %p-%i
|
2014-10-28 15:10:30 +00:00
|
|
|
|