init
This commit is contained in:
parent
8fb62b91b1
commit
8c7e8fbe05
15 changed files with 345 additions and 0 deletions
41
templates/lstu-updater.j2
Normal file
41
templates/lstu-updater.j2
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -eu
|
||||
|
||||
LSTU_PATH={{ lstu.path }}
|
||||
INSTALLED_VERSION=$(cd $LSTU_PATH && git for-each-ref --sort=-taggerdate --count=1 --format '%(tag)' refs/tags)
|
||||
LATEST_VERSION=$(curl -s {{ lstu_api_url }} | jq '.[]' | jq -r '.name' | head -1)
|
||||
LSTU_CONF_TEMPLATE={{ lstu.path }}/lstu.conf.template
|
||||
|
||||
if [ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]; then
|
||||
echo "Lstu ist bereits aktuell."
|
||||
exit 0
|
||||
else
|
||||
echo "Deaktiviere Monitoring..."
|
||||
monit unmonitor {{ lstu_monit_name }}
|
||||
|
||||
echo "Stoppe Dienst..."
|
||||
systemctl stop {{ lstu_service }}
|
||||
|
||||
echo "Aktualisiere Git-Repository..."
|
||||
cd "$LSTU_PATH"
|
||||
git pull
|
||||
git checkout tags/"$LATEST_VERSION"
|
||||
|
||||
echo "Starte Dienst..."
|
||||
systemctl start {{ lstu_service }}
|
||||
sleep 10
|
||||
|
||||
echo "Aktiviere Monitoring..."
|
||||
monit monitor {{ lstu_monit_name }}
|
||||
sleep 10
|
||||
monit status {{ lstu_monit_name }}
|
||||
|
||||
if [ "$(md5sum $LSTU_CONF_TEMPLATE)" == "$(cat $LSTU_CONF_TEMPLATE.md5)" ]; then
|
||||
echo "Keine Aenderungen am Konfigurationstemplate"
|
||||
else
|
||||
echo "Es gibt Aenderungen an der lstu.conf.template." | mail -s "Lstu-Update: Nacharbeiten notwendig" lstu@admin.systemausfall.org
|
||||
fi
|
||||
md5sum "$LSTU_CONF_TEMPLATE" > "$LSTU_CONF_TEMPLATE".md5
|
||||
fi
|
18
templates/lstu.service.j2
Normal file
18
templates/lstu.service.j2
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Shortened URLs service
|
||||
Documentation=https://framagit.org/fiat-tux/hat-softwares/lstu
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User={{ lstu_user }}
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory={{ lstu.path }}
|
||||
PIDFile={{ lstu.path }}/script/hypnotoad.pid
|
||||
ExecStart=/usr/bin/carton exec hypnotoad script/lstu
|
||||
ExecStop=/usr/bin/carton exec hypnotoad -s script/lstu
|
||||
ExecReload=/usr/bin/carton exec hypnotoad script/lstu
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
4
templates/monit.j2
Normal file
4
templates/monit.j2
Normal file
|
@ -0,0 +1,4 @@
|
|||
check process lstu with pidfile {{ lstu.path }}/script/hypnotoad.pid
|
||||
start program = "/usr/bin/systemctl start {{ lstu_service }}"
|
||||
stop program = "/usr/bin/systemctl stop {{ lstu_service }}"
|
||||
if failed host {{ ansible_default_ipv4.address }} port 8080 with timeout 15 seconds for 3 times within 4 cycles then restart
|
18
templates/nginx-rp-site.j2
Normal file
18
templates/nginx-rp-site.j2
Normal file
|
@ -0,0 +1,18 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name {{ lstu.domain }};
|
||||
include snippets/letsencrypt.conf;
|
||||
location / { return 301 https://$http_host$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name {{ lstu.domain }};
|
||||
ssl_certificate /var/lib/dehydrated/certs/{{ lstu.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /var/lib/dehydrated/certs/{{ lstu.domain }}/privkey.pem;
|
||||
include /etc/nginx/snippets/add_headers.conf;
|
||||
include /etc/nginx/snippets/proxy-transfer.conf;
|
||||
include /etc/nginx/snippets/lstu.conf;
|
||||
location = /robots.txt { root /data/lstu/; }
|
||||
location / { proxy_pass http://{{ inventory_hostname }}:8080; }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue