Skip to content

Commit 3f3186a

Browse files
authored
Merge pull request #1097 from Rubiss/swag-auto-uptime-kuma
2 parents 070873e + 0759888 commit 3f3186a

File tree

2 files changed

+27
-9
lines changed
  • root/etc/s6-overlay/s6-rc.d/init-mod-swag-auto-uptime-kuma-add-package

2 files changed

+27
-9
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ In SWAG docker arguments, set an environment variable `DOCKER_MODS=linuxserver/m
1414

1515
Add additional environment variables to the SWAG docker image:
1616

17-
| Name | Required | Example | Description |
18-
| ---------------------- | -------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19-
| `UPTIME_KUMA_URL` | Yes | `http://uptime-kuma:3001/` | The URL to the Uptime Kuma instance. Please note this cannot be the domain that it configured by SWAG as during initialization phase of the container those domains are not yet available. Instead use the docker container name. |
20-
| `UPTIME_KUMA_USERNAME` | Yes | `admin` | Your Uptime Kuma username |
21-
| `UPTIME_KUMA_PASSWORD` | Yes | `password` | Your Uptime Kuma password |
17+
| Name | Required | Default | Example | Description |
18+
| ------------------------- | -------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| `UPTIME_KUMA_URL` | Yes | | `http://uptime-kuma:3001/` | The URL to the Uptime Kuma instance. Please note this cannot be the domain that it configured by SWAG as during initialization phase of the container those domains are not yet available. Instead use the docker container name. |
20+
| `UPTIME_KUMA_USERNAME` | Yes | | `admin` | Your Uptime Kuma username |
21+
| `UPTIME_KUMA_PASSWORD` | Yes | | `password` | Your Uptime Kuma password |
22+
| `UPTIME_KUMA_API_VERSION` | No | `1` | `2` | Set to `2` if using Uptime Kuma v2.x. Defaults to `1` for backwards compatibility with Uptime Kuma v1.x. |
2223

2324
Unfortunately Uptime Kuma does not provide API keys for it's Socket.io API at the moment and Username/Password have to be used.
2425

@@ -28,7 +29,7 @@ Finally, add `swag.uptime-kuma.enabled=true` label at minimum to each of your co
2829

2930
## Labels
3031

31-
This mod is utilizing the wonderful [Uptime Kuma API](https://github.com/lucasheld/uptime-kuma-api) library. It allows you configure nearly every property of the Monitors by defining Docker Labels. For detailed documentation of each of these properties please refer to the `add_monitor` endpoint in the [official documentation](https://uptime-kuma-api.readthedocs.io/en/latest/api.html#uptime_kuma_api.UptimeKumaApi.add_monitor).
32+
This mod utilizes the [Uptime Kuma API](https://github.com/lucasheld/uptime-kuma-api) library (v1) or [Uptime Kuma API v2](https://github.com/exaland/uptime-kuma-api-v2) library (v2) depending on your `UPTIME_KUMA_API_VERSION` setting. It allows you to configure nearly every property of the Monitors by defining Docker Labels. For detailed documentation of each of these properties please refer to the `add_monitor` endpoint in the [API documentation](https://uptime-kuma-api.readthedocs.io/en/latest/api.html#uptime_kuma_api.UptimeKumaApi.add_monitor).
3233

3334
| Label | Default Value | Example Value | Description |
3435
| -------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

root/etc/s6-overlay/s6-rc.d/init-mod-swag-auto-uptime-kuma-add-package/run

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22

33
echo "[mod-auto-uptime-kuma] Installing SWAG auto-uptime-kuma packages"
44

5-
if ! pip list 2>&1 | grep -q "uptime-kuma-api\|docker"; then
5+
# Default to v1 for backwards compatibility
6+
UPTIME_KUMA_API_VERSION="${UPTIME_KUMA_API_VERSION:-1}"
7+
8+
# Validate version and warn on invalid values
9+
if [[ "$UPTIME_KUMA_API_VERSION" != "1" && "$UPTIME_KUMA_API_VERSION" != "2" ]]; then
10+
echo "[mod-auto-uptime-kuma] Warning: Invalid UPTIME_KUMA_API_VERSION '$UPTIME_KUMA_API_VERSION', defaulting to v1"
11+
UPTIME_KUMA_API_VERSION="1"
12+
fi
13+
14+
if [[ "$UPTIME_KUMA_API_VERSION" == "2" ]]; then
15+
KUMA_PACKAGE="uptime-kuma-api-v2"
16+
echo "[mod-auto-uptime-kuma] Using Uptime Kuma API v2 (for Uptime Kuma 2.x)"
17+
else
18+
KUMA_PACKAGE="uptime-kuma-api"
19+
echo "[mod-auto-uptime-kuma] Using Uptime Kuma API v1 (for Uptime Kuma 1.x)"
20+
fi
21+
22+
if ! pip list 2>&1 | grep -q "^${KUMA_PACKAGE} " || ! pip list 2>&1 | grep -q "^docker "; then
623
echo "\
724
docker \
8-
uptime-kuma-api" >> /mod-pip-packages-to-install.list
9-
echo "[mod-auto-uptime-kuma] Successfuly installed packages"
25+
${KUMA_PACKAGE}" >> /mod-pip-packages-to-install.list
26+
echo "[mod-auto-uptime-kuma] Packages added to install list"
1027
else
1128
echo "[mod-auto-uptime-kuma] Packages already installed, skipping..."
1229
fi

0 commit comments

Comments
 (0)