merge wordpress-subdir, close #19
This commit is contained in:
parent
80a151df86
commit
84bb761f8d
13 changed files with 121 additions and 11 deletions
|
@ -1,8 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -e "/data/per-user/$USER/nginx/data/www-content/index.html" ]; then
|
||||
if [ -e "/data/per-user/$USER/nginx/data/git-url.txt" ]; then
|
||||
git clone `cat /data/per-user/$USER/nginx/data/git-url.txt` /data/per-user/$USER/nginx/data/www-content
|
||||
if [ -e "/data/per-user/$USER/nginx/data/GITURL" ]; then
|
||||
git clone `cat /data/per-user/$USER/nginx/data/GITURL` /data/per-user/$USER/nginx/data/www-content
|
||||
cd /data/per-user/$USER/nginx/data/www-content && git checkout master
|
||||
else
|
||||
mkdir -p /data/per-user/$USER/nginx/data/www-content
|
||||
echo Hello $USER > /data/per-user/$USER/nginx/data/www-content/index.html
|
||||
|
|
18
importers/wordpress-subdir.sh
Executable file
18
importers/wordpress-subdir.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -d "/data/per-user/$USER/wordpress-subdir/data" ]; then
|
||||
cd /data/per-user/$USER/
|
||||
tar xvzf /data/indiehosters/blueprints/wordpress.tgz
|
||||
fi
|
||||
|
||||
cat /data/per-user/$USER/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > /data/per-user/$USER/wordpress-subdir/.env
|
||||
|
||||
if [ ! -e "/data/per-user/$USER/wordpress-subdir/data/www-content/index.html" ]; then
|
||||
if [ -e "/data/per-user/$USER/wordpress-subdir/data/GITURL" ]; then
|
||||
git clone `cat /data/per-user/$USER/wordpress-subdir/data/GITURL` /data/per-user/$USER/wordpress-subdir/data/www-content
|
||||
cd /data/per-user/$USER/wordpress-subdir/data/www-content && git checkout master
|
||||
else
|
||||
mkdir -p /data/per-user/$USER/wordpress-subdir/data/www-content
|
||||
echo Hello $USER > /data/per-user/$USER/wordpress-subdir/data/www-content/index.html
|
||||
fi
|
||||
fi
|
|
@ -3,5 +3,6 @@
|
|||
if [ ! -d "/data/per-user/$USER/wordpress/data" ]; then
|
||||
cd /data/per-user/$USER/
|
||||
tar xvzf /data/indiehosters/blueprints/wordpress.tgz
|
||||
cat /data/per-user/$USER/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > /data/per-user/$USER/wordpress/.env
|
||||
fi
|
||||
|
||||
cat /data/per-user/$USER/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > /data/per-user/$USER/wordpress/.env
|
||||
|
|
|
@ -10,7 +10,7 @@ fi
|
|||
mkdir -p /data/per-user/$DOMAIN/$IMAGE/data
|
||||
if [ $# -ge 3 ]; then
|
||||
GITREPO=$3
|
||||
echo $GITREPO > /data/per-user/$DOMAIN/$IMAGE/data/git-url.txt
|
||||
echo $GITREPO > /data/per-user/$DOMAIN/$IMAGE/data/GITURL
|
||||
fi
|
||||
|
||||
# Start service for new site (and create the user). This will also enable the git puller.
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
#!/bin/bash -eux
|
||||
|
||||
if [ $# -ge 1 ]; then
|
||||
HOSTNAME=$1
|
||||
else
|
||||
echo "Usage: sh /data/indiehosters/scripts/setup.sh k1.you.indiehosters.net"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install cloud-config
|
||||
if [ -f /tmp/vagrantfile-user-data ]; then
|
||||
mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/vagrantfile-user-data
|
||||
|
@ -12,14 +19,15 @@ docker pull indiehosters/postfix-forwarder
|
|||
docker pull indiehosters/nginx
|
||||
docker pull indiehosters/mysql
|
||||
docker pull indiehosters/wordpress
|
||||
docker pull indiehosters/wordpress-subdir
|
||||
|
||||
# Install unit-files
|
||||
cp /data/indiehosters/unit-files/* /etc/systemd/system
|
||||
systemctl daemon-reload
|
||||
|
||||
# Activate default domain
|
||||
sh /data/indiehosters/scripts/activate-user.sh $1 nginx
|
||||
etcdctl set /services/default '{"app":"nginx", "hostname":"'$1'"}'
|
||||
sh /data/indiehosters/scripts/activate-user.sh $HOSTNAME nginx
|
||||
etcdctl set /services/default '{"app":"nginx", "hostname":"'$HOSTNAME'"}'
|
||||
|
||||
# Configure and start HAproxy
|
||||
mkdir -p /data/server-wide/haproxy/approved-certs
|
||||
|
|
2
unit-files/gitpuller@.path
Normal file
2
unit-files/gitpuller@.path
Normal file
|
@ -0,0 +1,2 @@
|
|||
[Path]
|
||||
PathExists=/data/per-user/%i/nginx/data/GITURL
|
|
@ -1,9 +1,6 @@
|
|||
[Unit]
|
||||
Description=nginx git puller
|
||||
|
||||
# Dependency ordering
|
||||
Before=nginx@%i.service
|
||||
|
||||
[Service]
|
||||
ExecStart=cd /data/per-user/%i/nginx/data/www-content && git pull
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[Path]
|
||||
PathExists=/data/per-user/%i/nginx/data/git-url.txt
|
|
@ -5,6 +5,7 @@ Description=%p-%i
|
|||
Requires=docker.service
|
||||
Requires=%p-importer@%i.service
|
||||
Requires=%p-discovery@%i.service
|
||||
Wants=gitpuller@%i.service
|
||||
|
||||
# Dependency ordering
|
||||
After=docker.service
|
||||
|
|
35
unit-files/wordpress-subdir-discovery@.service
Normal file
35
unit-files/wordpress-subdir-discovery@.service
Normal file
|
@ -0,0 +1,35 @@
|
|||
[Unit]
|
||||
Description=%p for %i etcd registration
|
||||
|
||||
# Requirements
|
||||
Requires=etcd.service
|
||||
Requires=wordpress-subdir@%i.service
|
||||
|
||||
# Dependency ordering
|
||||
After=etcd.service
|
||||
After=wordpress-subdir@%i.service
|
||||
|
||||
# Dependency binding
|
||||
BindsTo=wordpress-subdir@%i.service
|
||||
|
||||
[Service]
|
||||
# Start
|
||||
## Test whether service is accessible and then register useful information
|
||||
ExecStart=/bin/bash -c ' \
|
||||
sleep 3; \
|
||||
while true; do \
|
||||
app=`echo %p | cut -d"-" -f1,2`; \
|
||||
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $app-%i`; \
|
||||
curl -f $ip; \
|
||||
if [ $? -eq 0 ]; then \
|
||||
etcdctl set /services/$app/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 60; \
|
||||
else \
|
||||
etcdctl rm /services/$app/%i; \
|
||||
fi; \
|
||||
sleep 50; \
|
||||
done'
|
||||
|
||||
# Stop
|
||||
ExecStop=/bin/bash -ceux ' \
|
||||
app=`echo %p | cut -d"-" -f1`; \
|
||||
/usr/bin/etcdctl rm /services/$app/%i
|
15
unit-files/wordpress-subdir-importer@.service
Normal file
15
unit-files/wordpress-subdir-importer@.service
Normal file
|
@ -0,0 +1,15 @@
|
|||
[Unit]
|
||||
Description=wordpress-subdir importer
|
||||
|
||||
# Dependency ordering
|
||||
After=mysql-importer@%i.service
|
||||
Before=wordpress-subdir@%i.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
Environment=USER=%i
|
||||
ExecStart=/data/indiehosters/importers/wordpress-subdir.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=wordpress-subdir@%i.service
|
34
unit-files/wordpress-subdir@.service
Normal file
34
unit-files/wordpress-subdir@.service
Normal file
|
@ -0,0 +1,34 @@
|
|||
[Unit]
|
||||
Description=%p-%i
|
||||
|
||||
# Requirements
|
||||
Requires=docker.service
|
||||
Requires=etcd.service
|
||||
Requires=mysql@%i.service
|
||||
Requires=%p-importer@%i.service
|
||||
Requires=%p-discovery@%i.service
|
||||
Wants=gitpuller@%i.service
|
||||
|
||||
# Dependency ordering
|
||||
After=docker.service
|
||||
After=mysql@%i.service
|
||||
After=%p-importer@%i.service
|
||||
Before=%p-discovery@%i.service
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
ExecStartPre=-/usr/bin/docker kill %p-%i
|
||||
ExecStartPre=-/usr/bin/docker rm %p-%i
|
||||
ExecStart=/usr/bin/docker run \
|
||||
--name %p-%i \
|
||||
--link mysql-%i:db \
|
||||
-v /data/per-user/%i/%p/data/wp-content:/wordpress/wp-content \
|
||||
-v /data/per-user/%i/%p/data/.htaccess:/wordpress/.htaccess \
|
||||
-v /data/per-user/%i/%p/data/www-content:/app \
|
||||
--env-file /data/per-user/%i/%p/.env \
|
||||
indiehosters/wordpress-subdir
|
||||
ExecReload=/usr/bin/docker restart %p-%i
|
||||
ExecStop=/usr/bin/docker stop %p-%i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in a new issue