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 205 additions and 115 deletions
[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/ -mindepth 3 -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 /dev/log:/dev/log \
-v /data/runtime/haproxy:/etc/haproxy \
-p 80:80 \
-p 443:443 \
haproxy haproxy -f /etc/haproxy/haproxy.cfg
ExecReload=/usr/bin/docker restart %p
ExecStop=/usr/bin/docker stop %p
[Service]
Type=oneshot
ExecStart=/libre.sh/utils/mail-mon.sh
[Unit] [Unit]
Description=Daily timer for OCSP stapling Description=Run mail mon hourly and on boot
[Timer] [Timer]
OnBootSec=15min OnBootSec=15min
OnUnitActiveSec=1day OnUnitActiveSec=1h
[Install] [Install]
WantedBy=multi-user.target WantedBy=timers.target
[Unit]
Description=Get the OCSP data from the cert provider
[Service]
Type=oneshot
TimeoutStartSec=0
ExecStart=/bin/bash -euxc ' \
for cert in `ls /data/runtime/haproxy/approved-certs/*.pem`;do \
/data/indiehosters/utils/ocsp.sh $cert; \
done; \
systemctl restart haproxy; \
rm /tmp/*.crt'
...@@ -12,10 +12,12 @@ Restart=always ...@@ -12,10 +12,12 @@ Restart=always
RestartSec=10 RestartSec=10
TimeoutStartSec=60 TimeoutStartSec=60
TimeoutStopSec=15 TimeoutStopSec=15
WorkingDirectory=/media/diskb/backup/ EnvironmentFile=-/system/%i/env
ExecStartPre=-/opt/bin/docker-compose rm -f Environment=HOSTNAME=%H
ExecStart=/opt/bin/docker-compose up WorkingDirectory=/system/%i/
ExecStop=/opt/bin/docker-compose stop ExecStartPre=-docker-compose rm -f
ExecStart=/bin/bash -euxc "docker-compose up"
ExecStop=docker-compose stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
[Unit] [Unit]
Description=Turn on swap Description=Turn on swap
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/sbin/swapon /data/swap RemainAfterExit=true
ExecStartPre=-/bin/bash -euxc ' \
fallocate -l 8192m /swap &&\
chmod 600 /swap &&\
mkswap /swap'
ExecStart=/sbin/swapon /swap
ExecStop=/sbin/swapoff /swap
[Install] [Install]
WantedBy=local.target WantedBy=local.target
...@@ -3,25 +3,21 @@ Description=%p-%i ...@@ -3,25 +3,21 @@ Description=%p-%i
# Requirements # Requirements
Requires=docker.service Requires=docker.service
Requires=d-u@%i.service
Requires=b-u@%i.timer
# Dependency ordering # Dependency ordering
After=docker.service After=docker.service
Before=d-u@%i.service
Before=b-u@%i.timer
[Service] [Service]
Restart=always Restart=always
RestartSec=10 RestartSec=10
TimeoutStartSec=60 TimeoutStartSec=60
TimeoutStopSec=15 TimeoutStopSec=15
EnvironmentFile=-/data/domains/%i/env
Environment=HOSTNAME=%H
WorkingDirectory=/data/domains/%i/ WorkingDirectory=/data/domains/%i/
ExecStartPre=/bin/cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem ExecStartPre=-docker-compose rm -f
ExecStartPre=-/opt/bin/docker-compose rm -f ExecStart=/bin/bash -euxc "LETSENCRYPT_HOST=%i VIRTUAL_HOST=%i,www.%i docker-compose up"
ExecStart=/opt/bin/docker-compose up ExecStop=docker-compose stop
ExecStop=/opt/bin/docker-compose stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
[Unit]
Description=%p-%i
# Requirements
Requires=docker.service
Requires=discovery-u@%i.service
Requires=backup-u@%i.timer
# Dependency ordering
After=docker.service
Before=discovery-u@%i.service
Before=backup-u@%i.timer
[Service]
Restart=always
RestartSec=10
TimeoutStartSec=60
TimeoutStopSec=15
WorkingDirectory=/data/domains/%i/
ExecStartPre=/bin/cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem
ExecStart=/bin/bash -euxc '/data/domains/%i/RUN'
ExecStop=/bin/bash -euxc '/data/domains/%i/STOP'
[Install]
WantedBy=multi-user.target
[Unit]
Description=Create lb_web network
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/docker network create lb_web
ExecStop=/usr/bin/docker network rm lb_web
[Install]
WantedBy=local.target
#cloud-config
ssh_authorized_keys:
- "PUT YOUR SSH KEY PUBLIC HERE"
write_files:
- path: /etc/ssh/sshd_config
permissions: 0600
owner: root:root
content: |
# Use most defaults for sshd configuration.
UsePrivilegeSeparation sandbox
Subsystem sftp internal-sftp
PermitRootLogin no
AllowUsers core
PasswordAuthentication no
ChallengeResponseAuthentication no
- path: /etc/sysctl.d/libresh.conf
permissions: 0644
owner: root
content: |
fs.aio-max-nr=1048576
vm.max_map_count=262144
vm.overcommit_memory=1
vm.nr_hugepages=0
- path: /etc/hosts
permissions: 0644
owner: root
content: |
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
- path: /etc/environment
permissions: 0644
owner: root
content: |
NAMECHEAP_URL="namecheap.com"
NAMECHEAP_API_USER="pierreo"
NAMECHEAP_API_KEY=
IP=`curl -s http://icanhazip.com/`
FirstName="Pierre"
LastName="Ozoux"
Address=""
PostalCode=""
Country="Portugal"
Phone="+351.967184553"
EmailAddress="pierre@ozoux.net"
City="Lisbon"
CountryCode="PT"
BACKUP_DESTINATION=root@xxxxx:port
MAIL_USER=
MAIL_PASS=
MAIL_HOST=mail.indie.host
MAIL_PORT=587
coreos:
update:
reboot-strategy: off
units:
- name: systemd-sysctl.service
command: restart
- name: swap.service
enable: true
command: start
content: |
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=-/bin/bash -euxc ' \
fallocate -l 8192m /swap &&\
chmod 600 /swap &&\
mkswap /swap'
ExecStart=/sbin/swapon /swap
ExecStop=/sbin/swapoff /swap
[Install]
WantedBy=local.target
- name: install-compose.service
command: start
content: |
[Unit]
Description=Install Docker Compose
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/bin/bash -euxc ' \
mkdir -p /opt/bin &&\
url=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r \'.assets[].browser_download_url | select(contains("Linux") and contains("x86_64"))\') &&\
curl -L $url > /opt/bin/docker-compose &&\
chmod +x /opt/bin/docker-compose'
- name: install-libresh.service
command: start
content: |
[Unit]
Description=Install libre.sh
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/bin/bash -euxc ' \
git clone https://github.com/indiehosters/libre.sh.git /libre.sh &&\
mkdir /{data,system} &&\
mkdir /data/trash &&\
cp /libre.sh/unit-files/* /etc/systemd/system && systemctl daemon-reload &&\
systemctl enable web-net.service &&\
systemctl start web-net.service &&\
cp /libre.sh/utils/* /opt/bin/'
#!/bin/bash -eux
source /etc/environment
user=$1
email=$2
quota=$3
curl -X POST -H "OCS-APIRequest:true" --user ${cloud_admin}:${cloud_pass} https://${cloud_hostname}/ocs/v1.php/cloud/users -d userid="$1" -d password="`tr -dc A-Za-z0-9_ < /dev/urandom | head -c 10 | xargs`"
curl -X PUT -H "OCS-APIRequest:true" --user ${cloud_admin}:${cloud_pass} https://${cloud_hostname}/ocs/v1.php/cloud/users/${user} -d key="email" -d value="${email}"
curl -X PUT -H "OCS-APIRequest:true" --user ${cloud_admin}:${cloud_pass} https://${cloud_hostname}/ocs/v1.php/cloud/users/${user} -d key="quota" -d value="${quota}"
File moved
#!/bin/bash -eux
source /etc/environment
user=$1
group=$2
curl -X POST -H "OCS-APIRequest:true" --user ${cloud_admin}:${cloud_pass} https://${cloud_hostname}/ocs/v1.php/cloud/users/${1}/groups -d groupid="${2}"
#!/bin/bash -eux
source /etc/environment
email=$1
cc_welcome_email=$2
quota=$3
password=`tr -dc A-Za-z0-9_ < /dev/urandom | head -c 10 | xargs`
local_part=`echo $email | cut -d@ -f1`
email_domain=`echo $email | cut -d@ -f2`
curl --data "username=${mail_username}&password=${mail_password}&login=Log+In&rememberme=0" -c /tmp/cookie.txt https://${mail_hostname}/auth/login
if ! curl -b /tmp/cookie.txt https://${mail_hostname}/domain | grep $email_domain | grep purge-domain | grep -o 'purge-domain-[0-9]*' | grep -o '[0-9]*' ; then
curl --data "backupmx=0&active=1&max_aliases=0&max_mailboxes=0&max_quota=0&quota=0&transport=virtual&domain=${email_domain}" -b /tmp/cookie.txt https://${mail_hostname}/domain/add
fi
domain_id=`curl -b /tmp/cookie.txt https://${mail_hostname}/domain | grep $email_domain | grep purge-domain | grep -o 'purge-domain-[0-9]*' | grep -o '[0-9]*'`
curl --data "local_part=${local_part}&domain=${domain_id}&password=${password}&welcome_email=1&cc_welcome_email=${cc_welcome_email}" -b /tmp/cookie.txt https://${mail_hostname}/mailbox/add
rm /tmp/cookie.txt
curl -X PUT --user ${cloud_admin}:${cloud_pass} https://${cloud_hostname}/ocs/v1.php/cloud/users/${email} -d key="quota" -d value="${quota}"
#docker exec -it --user www-data `echo ${cloud_hostname}_app_1 |sed 's/-//g' | sed 's/\.//g'` bash -c "\
# php occ mail:account:create ${email} ${email} ${email} ${mail_hostname} 993 ssl ${email} ${password} ${mail_hostname} 587 tls ${email} ${password}"
#!/bin/bash -eux
domain=$1
echo "/etc/haproxy/approved-certs/$domain.pem $domain" >> /data/runtime/haproxy/crt-list
echo "/etc/haproxy/approved-certs/$domain.pem www.$domain" >> /data/runtime/haproxy/crt-list