From d09ba4394bae18126880d401f8a0ae9697608282 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Fri, 26 Mar 2021 16:21:15 +0100 Subject: [PATCH 1/2] fixed permissions issue --- transmission/Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/transmission/Dockerfile b/transmission/Dockerfile index 9e2b2f6..a4eee7f 100644 --- a/transmission/Dockerfile +++ b/transmission/Dockerfile @@ -33,9 +33,17 @@ RUN addgroup \ --ingroup transmission \ --disabled-password \ --shell /sbin/nologin \ - transmission + transmission && \ + mkdir -p \ + /var/lib/transmission/blocklists \ + /var/lib/transmission/downloads \ + /var/lib/transmission/incomplete \ + /var/lib/transmission/resume \ + /var/lib/transmission/torrents && \ + chown -R transmission:transmission /var/lib/transmission ENV TRANSMISSION_HOME /var/lib/transmission USER transmission +WORKDIR /var/lib/transmission CMD ["/usr/local/bin/transmission-daemon", "--foreground"] From 6863926cf795b91c00ee8827b30dea84121c60a9 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Sat, 10 Apr 2021 18:37:36 +0200 Subject: [PATCH 2/2] nfs-server --- Makefile | 5 ++- README.md | 1 + nfs-server/Dockerfile | 15 +++++++++ nfs-server/Makefile | 10 ++++++ nfs-server/entrypoint.sh | 72 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 nfs-server/Dockerfile create mode 100644 nfs-server/Makefile create mode 100644 nfs-server/entrypoint.sh diff --git a/Makefile b/Makefile index 77ef4ca..8a76cc8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -images=agate archivebox ansible backup buku ddclient git-daemon gitolite gitolite-pystagit rss-bridge pleroma sassc syncthing tasks tor transmission vdirsyncer xandikos +images=agate archivebox ansible backup buku ddclient git-daemon gitolite gitolite-pystagit rss-bridge pleroma sassc syncthing tasks tor transmission vdirsyncer xandikos nfs-server .PHONY: all $(images) all: $(images) @@ -31,6 +31,9 @@ gitolite: gitolite-pystagit: $(BUILD) +nfs-server: + $(BUILD) + rss-bridge: $(BUILD) diff --git a/README.md b/README.md index 0c1ebac..4256944 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ useful. * gitolite-pystagit: well, gitolite + pystagit * gitolite: gitolite + docker, so that I can mount the docker socket inside of it and have it do useful things through docker in response to triggers +* nfs-server * pleroma * sassc * syncthing diff --git a/nfs-server/Dockerfile b/nfs-server/Dockerfile new file mode 100644 index 0000000..bff5b3e --- /dev/null +++ b/nfs-server/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.13 + +COPY entrypoint.sh /usr/local/bin/entrypoint + +RUN apk add --no-cache nfs-utils && \ + rm /etc/idmapd.conf /etc/exports && \ + mkdir -p /var/lib/nfs/rpc_pipefs /var/lib/nfs/v4recovery && \ + echo "rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0" >> /etc/fstab && \ + echo "nfsd /proc/fs/nfsd nfsd defaults 0 0" >> /etc/fstab && \ + chmod +x /usr/local/bin/entrypoint + +EXPOSE 2049 +ENTRYPOINT ["/usr/local/bin/entrypoint"] + + diff --git a/nfs-server/Makefile b/nfs-server/Makefile new file mode 100644 index 0000000..dd14738 --- /dev/null +++ b/nfs-server/Makefile @@ -0,0 +1,10 @@ +USERNAME = rilla +IMG_NAME = nfs-server + +.PHONY: build build-nc + +build: Dockerfile entrypoint.sh + docker build -t $(USERNAME)/$(IMG_NAME) . + +build-nc: Dockerfile entrypoint.sh + docker build --no-cache -t $(USERNAME)/$(IMG_NAME) . diff --git a/nfs-server/entrypoint.sh b/nfs-server/entrypoint.sh new file mode 100644 index 0000000..7ad9a99 --- /dev/null +++ b/nfs-server/entrypoint.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +NTHREADS=${NTHREADS:=1} + +stop () { + echo "un-exporting filesystems" + /usr/sbin/exportfs -uav + + echo "terminating nfsd" + /usr/sbin/rpc.nfsd 0 + + echo "killing pids" + pid1=$(pidof rpc.nfsd) + pid2=$(pidof rpc.mountd) + pid3=$(pidof rpc.rpcbind) + kill -TERM "$pid1" "$pid2" "$pid3" + + echo "un-mounting /var/lib/nfs/rpc_pipefs" + umount /var/lib/nfs/rpc_pipefs + + echo "un-mounting /proc/nfs/nfsd" + umount /proc/fs/nfsd + + exit 0 +} + +boot () { + + echo "mounting /var/lib/nfs/rpc_pipefs" + /bin/mount -t rpc_pipefs /var/lib/nfs/rpc_pipefs + echo "mounting /proc/fs/nfsd" + /bin/mount -t nfsd /proc/fs/nfsd + + echo "starting rpcbind" + /sbin/rpcbind -sw + /sbin/rpcinfo + + echo "exporting filesystems" + /usr/sbin/exportfs -ar + cat /etc/exports + + echo "starting mountd" + /usr/sbin/rpc.mountd \ + --port 32767 \ + --nfs-version 4 \ + --no-nfs-version 2 \ + --no-nfs-version 3 + + echo "starting nfsd" + /usr/sbin/rpc.nfsd \ + --tcp \ + --udp \ + --port 2049 \ + --nfs-version 4 \ + --no-nfs-version 2 \ + --no-nfs-version 3 \ + "${NTHREADS}" + + echo "terminating rpcbind" + pid=$(pidof rpcbind) + [ -n "$pid" ] && kill "$pid" + + echo "ready" +} + +trap stop TERM INT +boot + +while :; do + sleep 2073600 & + wait +done