43 lines
1.1 KiB
Desktop File
43 lines
1.1 KiB
Desktop File
[Unit]
|
|
Description=%p-%i
|
|
|
|
# Requirements
|
|
Requires=docker.service
|
|
|
|
# Dependency ordering
|
|
After=docker.service
|
|
Before=backup@%i.timer
|
|
|
|
# Dependency binding
|
|
BindsTo=lamp@%i.service
|
|
|
|
[Service]
|
|
Restart=always
|
|
RestartSec=20
|
|
TimeoutStartSec=0
|
|
Type=notify
|
|
NotifyAccess=all
|
|
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
|
|
ExecStartPre=-/usr/bin/docker kill %p-%i
|
|
ExecStartPre=-/usr/bin/docker rm %p-%i
|
|
ExecStartPre=/bin/bash -euxc ' \
|
|
mysql_folder=/data/domains/%i/mysql; \
|
|
if [ ! -d /data/runtime/domains/%i/mysql ]; then \
|
|
mkdir -p /data/runtime/domains/%i/mysql/db_files; \
|
|
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'
|
|
|
|
ExecStart=/opt/bin/systemd-docker run \
|
|
--rm \
|
|
--name %p-%i \
|
|
-v /data/runtime/domains/%i/log/mysql:/var/log/mysql \
|
|
-v /data/runtime/domains/%i/%p/db_files:/var/lib/mysql \
|
|
--env-file /data/domains/%i/%p/.env \
|
|
indiepaas/mysql
|
|
ExecReload=/usr/bin/docker restart %p-%i
|
|
ExecStop=/usr/bin/docker stop %p-%i
|
|
|