nfs-server

main
Ricard Illa 2021-04-10 18:37:36 +02:00
parent d09ba4394b
commit 6863926cf7
5 changed files with 102 additions and 1 deletions

View File

@ -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) .PHONY: all $(images)
all: $(images) all: $(images)
@ -31,6 +31,9 @@ gitolite:
gitolite-pystagit: gitolite-pystagit:
$(BUILD) $(BUILD)
nfs-server:
$(BUILD)
rss-bridge: rss-bridge:
$(BUILD) $(BUILD)

View File

@ -27,6 +27,7 @@ useful.
* gitolite-pystagit: well, gitolite + pystagit * gitolite-pystagit: well, gitolite + pystagit
* gitolite: gitolite + docker, so that I can mount the docker socket inside of * 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 it and have it do useful things through docker in response to triggers
* nfs-server
* pleroma * pleroma
* sassc * sassc
* syncthing * syncthing

15
nfs-server/Dockerfile Normal file
View File

@ -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"]

10
nfs-server/Makefile Normal file
View File

@ -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) .

72
nfs-server/entrypoint.sh Normal file
View File

@ -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