Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • lupa/compose.libre.sh
  • libre.sh/compose.libre.sh
  • ecobytes/compose.libre.sh
  • jordan.mitchell/compose.libre.sh
  • timothee/compose.libre.sh
5 results
Show changes
Showing
with 15 additions and 391 deletions
#!/bin/bash -eux
ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
# check if there are already running servers
if [ "$(cat /etc/hosts | grep -q '.test' ; echo $?)" -eq 0 ]; then
echo "It looks like some servers are still running."
echo "please run ./script.stop.sh first if you want to create new servers."
exit 1
fi
# Create backup for tests
$ROOT_DIR/scripts/create_vultr.sh backup.test
scp $ROOT_DIR/configs/backup.config root@backup.test:/var/lib/coreos-user_data
ssh root@backup.test /usr/bin/coreos-cloudinit --from-file=/var/lib/coreos-user_data
BACKUP_IP=`cat /etc/hosts | grep backup.test | cut -d" " -f1`
# Create server for tests
$ROOT_DIR/scripts/create_vultr.sh server.test 30
cat $ROOT_DIR/configs/server.config | sed s/##BACKUP_IP##/$BACKUP_IP/g > /tmp/server.config
scp /tmp/server.config root@server.test:/var/lib/coreos-user_data
scp $ROOT_DIR/scripts/install.sh root@server.test:/tmp/install.sh
ssh root@server.test /tmp/install.sh
IP=`cat /etc/hosts | grep server.test | cut -d" " -f1`
# Adds ip to /etc/hosts file
echo "We'll now modify your /etc/hosts to add the test application name"
applications=( `cat $ROOT_DIR/SUPPORTED_APPLICATIONS` )
for application in "${applications[@]}"
do
echo Writing $application.test to /etc/hosts file, needs your root password:
sudo -- sh -c "echo $IP $application.test >> /etc/hosts"
done
# cleaning
rm /tmp/server.config
#!/bin/bash -eux
ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
$ROOT_DIR/scripts/destroy_vultr.sh backup.test
ssh-keygen -f ~/.ssh/known_hosts -R backup.test
$ROOT_DIR/scripts/destroy_vultr.sh server.test
ssh-keygen -f ~/.ssh/known_hosts -R server.test
applications=( `cat $ROOT_DIR/SUPPORTED_APPLICATIONS` )
for application in "${applications[@]}"
do
sudo sed -i "/$application.test/ d" /etc/hosts
done
[Unit]
Description=Back up data from %i
[Service]
Type=oneshot
TimeoutStartSec=0
WorkingDirectory=/data/domains/%i/
EnvironmentFile=/etc/environment
ExecStartPre=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name clean-%i \
-e PASSPHRASE \
-v /root:/root \
indiepaas/duplicity \
remove-older-than 10D --force \
sftp://${BACKUP_DESTINATION}/%i'
ExecStartPre=/bin/bash -euxc '/data/domains/%i/BACKUP'
ExecStart=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name backup-%i \
-e PASSPHRASE \
-h backup.container \
--cpu-shares=40 \
-v /dev/random:/dev/random \
-v /dev/urandom:/dev/urandom \
-v /root:/root \
-v /data/domains/%i:/backup indiepaas/duplicity \
--volsize 500 \
--asynchronous-upload \
--encrypt-key ${ENCRYPT_KEY} \
/backup \
sftp://${BACKUP_DESTINATION}/%i'
[Unit]
Description=Hourly backup of www and mysql content.
# Dependency binding
BindsTo=u@%i.service
[Timer]
OnActiveSec=20
OnUnitActiveSec=60min
AccuracySec=50min
[Unit]
Description=Back up data from %i
[Service]
Type=oneshot
TimeoutStartSec=0
WorkingDirectory=/data/domains/%i/
EnvironmentFile=/etc/environment
ExecStartPre=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name clean-%i \
-e PASSPHRASE \
-v /root:/root \
indiepaas/duplicity \
remove-older-than 10D --force \
sftp://${BACKUP_DESTINATION}/%i'
ExecStartPre=/bin/bash -euxc '/data/domains/%i/BACKUP'
ExecStart=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name backup-%i \
-e PASSPHRASE \
-h backup.container \
--cpu-shares=40 \
-e PASSPHRASE \
-v /dev/random:/dev/random \
-v /dev/urandom:/dev/urandom \
-v /root:/root \
-v /data/domains/%i:/backup indiepaas/duplicity \
--volsize 500 \
--asynchronous-upload \
--encrypt-key ${ENCRYPT_KEY} \
/backup \
sftp://${BACKUP_DESTINATION}/%i'
[Unit]
Description=Hourly backup of www and mysql content.
# Dependency binding
BindsTo=universal@%i.service
[Timer]
OnActiveSec=20
OnUnitActiveSec=60min
AccuracySec=50min
[Unit]
Description=Back up data from %i
[Service]
Type=oneshot
TimeoutStartSec=0
EnvironmentFile=/etc/environment
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
ExecStartPre=-/usr/bin/docker kill mysqldump-%i
ExecStartPre=-/usr/bin/docker rm mysqldump-%i
ExecStartPre=-/usr/bin/docker rm clean-%i
ExecStartPre=-/usr/bin/docker rm backup-%i
ExecStartPre=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name clean-%i \
-e PASSPHRASE \
-v /root:/root \
indiepaas/duplicity \
remove-older-than 10D --force \
sftp://${BACKUP_DESTINATION}/%i'
ExecStartPre=/bin/bash -euxc '\
if [ -d /data/domains/%i/mysql ]; then \
echo "Backing up mysql databases for %i"; \
mysql_passwd=`cat /data/domains/%i/mysql/.env | cut -d= -f2`; \
/usr/bin/docker run \
--rm \
--name mysqldump-%i \
--link mysql-%i:db \
--env-file /data/domains/%i/mysql/.env \
indiepaas/mysql \
mysqldump \
--all-databases \
--events \
-uadmin \
-p$mysql_passwd \
-h db > /data/domains/%i/mysql/dump.sql; \
fi'
ExecStart=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name backup-%i \
--cpu-shares=40 \
-e PASSPHRASE \
-h backup.container \
-v /dev/random:/dev/random \
-v /dev/urandom:/dev/urandom \
-v /root:/root \
-v /data/domains/%i:/backup indiepaas/duplicity \
--volsize 500 \
--asynchronous-upload \
--encrypt-key ${ENCRYPT_KEY} \
/backup \
sftp://${BACKUP_DESTINATION}/%i'
[Unit]
Description=Hourly backup of www and mysql content.
# Dependency binding
BindsTo=web@%i.service
[Timer]
OnActiveSec=20
OnUnitActiveSec=60min
AccuracySec=50min
[Unit]
Description=%p
# Requirements
Requires=docker.service
Requires=etcd.service
# Dependency ordering
After=docker.service
After=etcd.service
Before=haproxy.service
[Service]
Restart=always
RestartSec=20
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill %p
ExecStartPre=-/usr/bin/docker rm %p
ExecStart=/usr/bin/docker run \
--rm \
--name %p \
-v /data/runtime/haproxy/:/etc/haproxy/ \
-v /var/run/docker.sock:/var/run/docker.sock \
indiepaas/confd
ExecReload=/usr/bin/docker restart %p
ExecStop=/usr/bin/docker stop %p
[Install]
WantedBy=multi-user.target
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
# Dependency binding
BindsTo=u@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=URL=%i
ExecStart=/bin/bash -xc ' \
ip=""; \
while [ -z $ip ]; \
do \
container_name=`echo ${URL}_web_1 | sed "s/\.//g" | sed "s/-//g"`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $container_name`; \
sleep 1; \
done; \
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
# Dependency binding
BindsTo=universal@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=URL=%i
ExecStart=/bin/bash -xc ' \
ip=""; \
while [ -z $ip ]; \
do \
container_name=`echo ${URL}_web_1 | sed "s/\.//g" | sed "s/-//g"`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $container_name`; \
sleep 1; \
done; \
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
# Dependency binding
BindsTo=web@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -euxc ' \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' %i`; \
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i
[Service]
Type=oneshot
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
ExecStart=/opt/bin/dump_all.sh
[Unit]
Description=Run dump all dayly
[Timer]
OnCalendar=*-*-* 00:15:30
[Install]
WantedBy=timers.target
[Unit]
Description=Git pull on every git repo
[Service]
Type=oneshot
TimeoutStartSec=0
ExecStart=/bin/bash -euxc ' \
for directory in `find /data/domains/ -name .git -type d -prune -not -path "*/owncloud/data/*"`;do \
cd $directory; cd ..;\
git pull; \
done'
[Unit]
Description=Git pull every 5 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
[Install]
WantedBy=multi-user.target
[Path]
PathExists=/data/runtime/haproxy/haproxy.cfg
[Install]
WantedBy=multi-user.target
[Unit]
Description=%p
# Requirements
Requires=docker.service
# Dependency ordering
After=docker.service
[Service]
Restart=always
RestartSec=20
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill %p
ExecStartPre=-/usr/bin/docker rm %p
ExecStart=/usr/bin/docker run \
--rm \
--name %p \
-v /data/runtime/haproxy:/etc/haproxy \
-p 80:80 \
-p 443:443 \
indiepaas/haproxy
ExecReload=/usr/bin/docker restart %p
ExecStop=/usr/bin/docker stop %p
[Unit]
Description=%p-%i
# Requirements
Requires=mysql@%i.service
Requires=web@%i.service
# Dependency ordering
After=mysql@%i.service
Before=web@%i.service
# Dependency binding
BindsTo=web@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/data/domains/%i/.env
ExecStart=/bin/bash -euxc ' \
application_folder=/data/domains/%i/${APPLICATION}; \
if [ ! -f $application_folder/.env ]; then \
cat /data/domains/%i/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > $application_folder/.env; \
fi;'
[Install]
WantedBy=multi-user.target
[Service]
Type=oneshot
ExecStart=/libre.sh/utils/mail-mon.sh