add warehost-ftp

This commit is contained in:
Martin Geno 2016-11-27 10:06:35 +01:00
parent 20674d5352
commit 94b808395c
16 changed files with 195 additions and 2 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@ mailserver/files/
warehost-api/files/ warehost-api/files/
warehost-web/files/ warehost-web/files/
warehost-host/files/ warehost-host/files/
warehost-ftp/files/

View File

@ -0,0 +1,6 @@
---
warehost_db_host: localhost
warehost_ftp_port: 22
warehost_ftp_data_path: /srv/ftp
warehost_ftp_host_path: /srv/http/domain
warehost_ftp_web_path: /srv/http/web

View File

@ -0,0 +1,6 @@
---
- name: reload daemon-reload
command: systemctl daemon-reload
- name: restart warehost-ftp
service: name=warehost-ftp state=restarted

View File

@ -0,0 +1,4 @@
---
dependencies:
- warehost-meta
- warehost-db

View File

@ -0,0 +1,19 @@
---
- name: Download Warehost-ftp (TODO current copy)
copy: src=warehost-ftp dest=/usr/local/bin/warehost-ftp owner=root group=root mode=0755
- name: Create data folder
file: path={{warehost_ftp_data_path}} state=directory owner=warehost group=http mode=0770
- name: Configurate warehost
template: src=config.yml dest=/etc/warehost/ftp.conf owner=warehost mode=0600
notify: restart warehost-ftp
- name: Install service
template: src=warehost-ftp.unit dest=/lib/systemd/system/warehost-ftp.service owner=root mode=644
notify:
- reload daemon-reload
- restart warehost-ftp
- name: Enable warehost
service: name=warehost-ftp state=started enabled=yes

View File

@ -0,0 +1,9 @@
---
database: "host={{warehost_db_host}} user={{warehost_db_user}} dbname={{warehost_db_dbname}} password={{warehost_db_pass}} sslmode=disable"
log:
path: /var/log/warehost/ftp.log
databasedebug: false
port: {{warehost_ftp_port}}
data: {{warehost_ftp_data_path}}/%d/
host: {{warehost_ftp_host_path}}/%s/
web: {{warehost_ftp_web_path}}/%d/

View File

@ -0,0 +1,15 @@
[Unit]
Description=Warehost ftp v2
After=syslog.target
After=network.target
After=postgresql.service
[Service]
Type=simple
User=warehost
Group=nobody
ExecStart=/usr/local/bin/warehost-ftp -c /etc/warehost/ftp.conf
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,10 @@
---
warehost_db_host: localhost
warehost_host_web_type: caddy
warehost_host_web_path: /etc/caddy/hosts/50-gen-warehost.act
warehost_host_web_webroot: /srv/http/domain
warehost_host_db_type: mysql
warehost_host_db_host: ""
warehost_host_db_user: root
warehost_host_db_pass: "{{ lookup('password', 'credentials/mysql_root length=15') }}"
warehost_host_db_prefix: warehost_db

View File

@ -0,0 +1,6 @@
---
- name: reload daemon-reload
command: systemctl daemon-reload
- name: restart warehost-host
service: name=warehost-host.timer state=restarted

View File

@ -0,0 +1,4 @@
---
dependencies:
- warehost-meta
- warehost-db

View File

@ -0,0 +1,26 @@
---
- name: Download Warehost-host (TODO current copy)
copy: src=warehost-host dest=/usr/local/bin/warehost-host owner=root group=root mode=0755
- name: Configurate warehost-host
template: src=config.yml dest=/etc/warehost/host.conf owner=warehost mode=0600
notify: restart warehost-host
- name: Configurate host template
template: src={{warehost_host_web_type}}.conf dest=/etc/warehost/host-web.tmpl owner=warehost mode=0600
notify: restart warehost-host
- name: Configurate warehost-host
file: path={{warehost_host_web_path}} state=touch owner=warehost group=http mode=0660
- name: Install service
template: src=warehost-host.{{item}} dest=/lib/systemd/system/warehost-host.{{item}} owner=root mode=644
with_items:
- service
- timer
notify:
- reload daemon-reload
- restart warehost-host
- name: Enable warehost
service: name=warehost-host.timer state=started enabled=yes

View File

@ -0,0 +1,49 @@
#jinja2:variable_start_string:'[%' , variable_end_string:'%]'
# ID: {{.ID}} - Domain: {{.Domain.ID}} - Profil: {{.Domain.Profil.ID}}
# Login: {{.Domain.Profil.Login.ID}} -> {{.Domain.Profil.Login.Username}}
# {{.Subdomain}} - {{.Domain.FQDN}}
{{ define "domain" }}{{if .Subdomain}}{{.Subdomain}}.{{end}}{{.Domain.FQDN}}{{ end }}
{{ define "content"}}
{{if not .Redirect}}
gzip
{{if .Proxy}}
proxy / {{.Proxy}}
{{else}}
root [% warehost_host_web_webroot %]/{{template "domain" .}}
{{if .PHP}}
fastcgi / unix:/run/php-fpm/php-fpm.sock php {
env PHP_ADMIN_VALUE "open_basedir=/tmp:/usr/share/webapps/:/etc/webapps/:/usr/share/pear:/dev/urandom:[% warehost_host_web_webroot %]/{{template "domain" .}}"
}
rewrite {
to {path} {path}/ /index.php?_url={uri}
}
{{end}}
{{end}}
{{else}}
redir https://{{.Redirect}}{uri}
{{end}}
{{end}}
{{if .SSL}}
{{if .SSLRedirect}}
http://{{template "domain".}} {
{{if not .Redirect}}
redir https://{{template "domain".}}{uri}
{{else}}
{{template "content" .}}
{{end}}
}
https://{{template "domain".}} {
{{template "content" .}}
}
{{else}}
http://{{template "domain" .}},https://{{template "domain".}} {
{{template "content" .}}
}
{{end}}
{{else}}
http://{{template "domain".}} {
{{template "content" .}}
}
{{end}}

View File

@ -0,0 +1,14 @@
---
warehostdatabase: "host={{warehost_db_host}} user={{warehost_db_user}} dbname={{warehost_db_dbname}} password={{warehost_db_pass}} sslmode=disable"
log:
path: /var/log/warehost/host.log
databasedebug: false
web:
enable: true
template: /etc/warehost/host-web.tmpl
config: {{warehost_host_web_path}}
database:
enable: true
type: {{warehost_host_db_type}}
connection: "{{warehost_host_db_user}}:{{warehost_host_db_pass}}@{{warehost_host_db_host}}/mysql?interpolateParams=true"
prefix: {{warehost_host_db_prefix}}

View File

@ -0,0 +1,16 @@
[Unit]
Description=Warehost host to configurate the Webserver and Database
After=syslog.target
After=network.target
After=postgresql.service
[Service]
Type=oneshot
User=warehost
Group=nobody
ExecStart=/usr/local/bin/warehost-host -c /etc/warehost/host.conf
PermissionsStartOnly=true
ExecStartPost=/usr/bin/systemctl reload {{warehost_host_web_type}}
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=Warehost host to configurate the Webserver and Database
[Timer]
OnBootSec=15min
OnUnitActiveSec=5min
[Install]
WantedBy=timers.target

View File

@ -2,4 +2,4 @@
warehost_db_host: localhost warehost_db_host: localhost
warehost_web_internal_ip: 127.0.0.1 warehost_web_internal_ip: 127.0.0.1
warehost_web_internal_port: 60000 warehost_web_internal_port: 60000
warehost_web_webroot: /srv/warehost-web warehost_web_webroot: /srv/http/web