From 20ba0467d14f6511decab170d261a3f22079301a Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Mon, 22 Aug 2022 18:28:36 +0200 Subject: [PATCH] sendxmpp --- Makefile | 5 ++++- sendxmpp/Dockerfile | 18 ++++++++++++++++++ sendxmpp/Makefile | 24 ++++++++++++++++++++++++ sendxmpp/entrypoint.sh | 31 +++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 sendxmpp/Dockerfile create mode 100644 sendxmpp/Makefile create mode 100644 sendxmpp/entrypoint.sh diff --git a/Makefile b/Makefile index c1123ef..34630d8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ REGISTRY=registry.monotremata.xyz PLATFORMS=linux/amd64,linux/arm64 -IMAGES=agate buildx-qemu mpd pleroma rainloop rsync static-page-builder tor transmission webdav +IMAGES=agate buildx-qemu mpd pleroma rainloop rsync sendxmpp static-page-builder tor transmission webdav .PHONY: all $(IMAGES) @@ -27,6 +27,9 @@ rainloop: rsync: $(BUILDX) +sendxmpp: + $(BUILDX) + static-page-builder: $(BUILDX) diff --git a/sendxmpp/Dockerfile b/sendxmpp/Dockerfile new file mode 100644 index 0000000..be4a782 --- /dev/null +++ b/sendxmpp/Dockerfile @@ -0,0 +1,18 @@ +FROM alpine:3.16 + +ADD entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh && \ + apk add --no-cache go-sendxmpp && \ + addgroup \ + --gid 10001 \ + sendxmpp && \ + adduser \ + --uid 10000 \ + --ingroup sendxmpp \ + --disabled-password \ + --shell /sbin/nologin \ + sendxmpp + +USER sendxmpp +ENTRYPOINT ["/entrypoint.sh"] diff --git a/sendxmpp/Makefile b/sendxmpp/Makefile new file mode 100644 index 0000000..5b33c4c --- /dev/null +++ b/sendxmpp/Makefile @@ -0,0 +1,24 @@ +IMG_NAME=sendxmpp +REGISTRY=registry.monotremata.xyz +IMG=$(REGISTRY)/$(IMG_NAME) +PLATFORMS=linux/amd64,linux/arm64 + +.PHONY: push buildx clean + +out/image-id: Dockerfile entrypoint.sh + mkdir -p $(@D) + docker build -t $(IMG) . + echo $(IMG) > $@ + +push: out/image-id + docker image push $(IMG) + +buildx: Dockerfile entrypoint.sh + docker buildx build \ + --platform $(PLATFORMS) \ + --tag $(IMG) \ + --push \ + . + +clean: + rm -rf out diff --git a/sendxmpp/entrypoint.sh b/sendxmpp/entrypoint.sh new file mode 100644 index 0000000..1bf7448 --- /dev/null +++ b/sendxmpp/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +MESSAGE="${MESSAGE:-${PLUGIN_MESSAGE}}" +if [ -z "$MESSAGE" ]; then + echo "'message' must specified" + exit 1 +fi + +USERNAME="${USERNAME:-${PLUGIN_USERNAME}}" +if [ -z "$USERNAME" ]; then + echo "'username' must specified" + exit 1 +fi + +PASSWORD="${PASSWORD:-${PLUGIN_PASSWORD}}" +if [ -z "$USERNAME" ]; then + echo "'username' must specified" + exit 1 +fi + +RECIPIENT="${RECIPIENT:-${PLUGIN_RECIPIENT}}" +if [ -z "$RECIPIENT" ]; then + echo "'recipient' must specified" + exit 1 +fi + +exec echo "$MESSAGE" | \ + go-sendxmpp \ + --username="${USERNAME}"\ + --password="${PASSWORD}" \ + "${RECIPIENT}"