2014-10-28 16:24:00 +00:00
|
|
|
[Unit]
|
2014-10-28 15:10:30 +00:00
|
|
|
Description=MySQL importer
|
2014-11-03 19:22:54 +00:00
|
|
|
|
|
|
|
# Dependency ordering
|
2014-10-28 15:10:30 +00:00
|
|
|
Before=mysql@%i.service
|
|
|
|
|
2014-11-03 19:22:54 +00:00
|
|
|
# Dependency binding
|
|
|
|
BindsTo=mysql@%i.service
|
|
|
|
|
2014-10-28 15:10:30 +00:00
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
RemainAfterExit=yes
|
2014-11-04 19:25:39 +00:00
|
|
|
ExecStart=/bin/bash -euxc ' \
|
2014-11-05 17:28:04 +00:00
|
|
|
mysql_folder=/data/domains/%i/mysql; \
|
|
|
|
if [ ! -d $mysql_folder ]; then \
|
|
|
|
mkdir -p $mysql_folder; \
|
2014-11-04 19:25:39 +00:00
|
|
|
pass=`echo $RANDOM ${date} | md5sum | base64 | cut -c-10`; \
|
2014-11-05 17:28:04 +00:00
|
|
|
echo MYSQL_PASS=$pass > $mysql_folder/.env; \
|
2014-11-04 19:25:39 +00:00
|
|
|
fi; \
|
2014-11-05 17:28:04 +00:00
|
|
|
if [ -f $mysql_folder/dump.sql ]; then \
|
|
|
|
echo develop import mysql feature; \
|
|
|
|
exit 1; \
|
|
|
|
else \
|
|
|
|
mkdir -p /data/runtime/domains/%i/mysql/db_files; \
|
|
|
|
fi'
|
2014-10-28 15:10:30 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=mysql@%i.service
|