From 485026be21222ce16d228ee95024e31e26d53cbc Mon Sep 17 00:00:00 2001 From: Aeris Date: Fri, 3 Sep 2021 02:46:08 +0200 Subject: [PATCH] docker-compose compatibility --- Dockerfile | 8 ++++++-- docker-entrypoint.sh | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 2ee7c8f..9b2a387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,8 +94,12 @@ RUN set -x \ FROM alpine -RUN apk add --no-cache ca-certificates +RUN apk add --no-cache ca-certificates sqlite COPY --from=builder /tmp/whatsxmpp /whatsxmpp -ENTRYPOINT /whatsxmpp +ADD schema.sql / + +ADD docker-entrypoint.sh / + +ENTRYPOINT /docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..120f7eb --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! -f /data/data.sqlite3 ]; then + echo "Creating new Database!" + sqlite3 /data/data.sqlite3 < /schema.sql + sqlite3 /data/data.sqlite3 "INSERT INTO configuration (rev, server, port, component_name, shared_secret, upload_component_name) VALUES (1, \"$SERVER\", \"$PORT\", \"$COMPONENT_NAME\", \"$SECRET\", \"$UPLOAD_NAME\"); " ".exit" + +fi + +if [ ! -z $MAM ]; then + sqlite3 /data/data.sqlite3 "UPDATE configuration SET allow_archiving = true;" ".exit" +fi +if [ ! -z $HISTORY ]; then + sqlite3 /data/data.sqlite3 "UPDATE configuration SET allow_history_fetches = true;" ".exit" +fi + +/whatsxmpp /data/data.sqlite3