Inital commit
This commit is contained in:
commit
fd5c78edb4
11 changed files with 245 additions and 0 deletions
24
templates/nginx.j2
Normal file
24
templates/nginx.j2
Normal file
|
@ -0,0 +1,24 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name {{ uptimekuma_domain }};
|
||||
include snippets/letsencrypt.conf;
|
||||
location / { return 301 https://$http_host$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name {{ uptimekuma_domain }};
|
||||
ssl_certificate /var/lib/dehydrated/certs/{{ uptimekuma_domain }}/fullchain.pem;
|
||||
ssl_certificate_key /var/lib/dehydrated/certs/{{ uptimekuma_domain }}/privkey.pem;
|
||||
include /etc/nginx/snippets/add_headers.conf;
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_pass http://{{ inventory_hostname }}:{{ uptimekuma_port }};
|
||||
}
|
||||
}
|
62
templates/uptime-kuma-updater.j2
Normal file
62
templates/uptime-kuma-updater.j2
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Update script for Uptime Kuma
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -eu
|
||||
|
||||
USER={{ uptimekuma_user }}
|
||||
PROJECT_URL={{ uptimekuma_github_api_url }}
|
||||
INSTALL_PATH={{ uptimekuma_home }}
|
||||
UPTIME_KUMA_SERVICE={{ uptimekuma_service }}
|
||||
VERSION_FILE={{ uptimekuma_version_file }}
|
||||
|
||||
get_latest_version() {
|
||||
curl -sL "$PROJECT_URL" | jq -r ".tag_name"
|
||||
}
|
||||
|
||||
get_installed_version() {
|
||||
# return the currently installed version (or empty, if not installed)
|
||||
cat "$VERSION_FILE" 2>/dev/null || true
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
ACTION=$1
|
||||
shift
|
||||
else
|
||||
ACTION=status
|
||||
fi
|
||||
|
||||
case "$ACTION" in
|
||||
status)
|
||||
printf 'Currently installed version:\t%s\n' "$(get_installed_version)"
|
||||
printf 'Latest available version:\t%s\n' "$(get_latest_version)"
|
||||
;;
|
||||
upgrade)
|
||||
wanted_version=${1:-latest}
|
||||
[ "$wanted_version" = "latest" ] && wanted_version=$(get_latest_version)
|
||||
if [ "$wanted_version" = "$(get_installed_version)" ]; then
|
||||
echo "Version '$wanted_version' is already installed. Nothing needs to be done."
|
||||
else
|
||||
echo "Update Uptime Kuma to latest version '$wanted_version' ..."
|
||||
cd "$INSTALL_PATH"
|
||||
systemctl stop "$UPTIME_KUMA_SERVICE"
|
||||
sudo -u "$USER" git fetch --all
|
||||
sudo -u "$USER" git checkout "$(get_latest_version)" --force
|
||||
sudo -u "$USER" npm install --production
|
||||
sudo -u "$USER" npm run download-dist
|
||||
sudo -u "$USER" echo "$(get_latest_version)" > "$VERSION_FILE"
|
||||
systemctl start "$UPTIME_KUMA_SERVICE"
|
||||
fi
|
||||
;;
|
||||
help|--help)
|
||||
echo "Syntax: $(basename "$0") ACTION"
|
||||
echo " upgrade [VERSION] - upgrade to the specified version (default: latest)"
|
||||
echo " status - output the currently installed and latest available version"
|
||||
echo
|
||||
;;
|
||||
*)
|
||||
"$0" help >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
24
templates/uptime-kuma.service.j2
Normal file
24
templates/uptime-kuma.service.j2
Normal file
|
@ -0,0 +1,24 @@
|
|||
[Unit]
|
||||
Description=Uptime-Kuma - A free and open source uptime monitoring solution
|
||||
Documentation=https://github.com/louislam/uptime-kuma
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ uptimekuma_user }}
|
||||
Environment=HOST=0.0.0.0
|
||||
Environment=PORT={{ uptimekuma_port }}
|
||||
WorkingDirectory={{ uptimekuma_home }}
|
||||
ExecStart=/usr/bin/npm run start-server
|
||||
Restart=on-failure
|
||||
|
||||
# Hardening to improve security
|
||||
ProtectControlGroups=true
|
||||
ProtectHome=true
|
||||
ProtectSystem=strict
|
||||
PrivateMounts=true
|
||||
PrivateTmp=true
|
||||
ReadWritePaths={{ uptimekuma_home }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
1
templates/version.j2
Normal file
1
templates/version.j2
Normal file
|
@ -0,0 +1 @@
|
|||
{{ latest_version.stdout }}
|
Loading…
Add table
Add a link
Reference in a new issue