diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..554eb02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:latest + +RUN apk --update add python git && \ + apk add snapraid --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing --allow-untrusted && \ + git clone https://github.com/Chronial/snapraid-runner.git /app/snapraid-runner && \ + chmod +x /app/snapraid-runner/snapraid-runner.py && \ + rm -rf /var/cache/apk/* + +RUN echo '0 3 * * * root /usr/bin/python /app/snapraid-runner/snapraid-runner.py -c /config/snapraid-runner.conf' > /etc/crontabs/root + +VOLUME /mnt /config + +COPY /docker-entry.sh / + +CMD ["/docker-entry.sh"] diff --git a/docker-entry.sh b/docker-entry.sh new file mode 100644 index 0000000..9437780 --- /dev/null +++ b/docker-entry.sh @@ -0,0 +1,27 @@ +#!/bin/ash +# Ensures that configuration files for both SnapRAID and snapraid-runner are present +# in /config. In reality, both files should be edited manually before running this +# container to ensure correct operation. + +# test for /etc/snapraid.conf being a file and not a link, delete if file. +if [ ! -L /etc/snapraid.conf ] && [ -f /etc/snapraid.conf ]; then + rm /etc/snapraid.conf +fi + +# test if snapraid.conf is in /config, copy from /defaults/snapraid.conf.example if not. +if [ ! -f /config/snapraid.conf ]; then + echo "No config found. You must configure SnapRAID before running this container." + exit 1 +fi +if [ ! -f /config/snapraid-runner.conf ]; then + echo "No config found. You must configure snapraid-runner before running this container" + exit 1 +fi + +# test if link is made between /etc/snapraid.conf and /config/snapraid.conf, make if not +if [ ! -L /etc/snapraid.conf ]; then + ln -s /config/snapraid.conf /etc/snapraid.conf +fi + +/usr/sbin/crond -c /etc/crontabs -f +