From 34188e8721f0ad72400688a68ec279af641053c4 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Mon, 3 Aug 2020 22:24:11 +0000 Subject: [PATCH] Tweak run scripts, adjust config/welcome scripts, finalize syncthing integration --- piframefleet/Dockerfile | 4 +-- .../cont-init.d/{99-welcome => 00-welcome} | 0 piframefleet/root/etc/cont-init.d/30-config | 26 ++++++++++++++++--- .../root/etc/services.d/_service_control/run | 0 .../root/etc/services.d/syncthing/run | 9 +++++++ .../root/etc/services.d/wireguard/run | 0 piframefleet_run.sh | 7 ++--- 7 files changed, 36 insertions(+), 10 deletions(-) rename piframefleet/root/etc/cont-init.d/{99-welcome => 00-welcome} (100%) mode change 100644 => 100755 mode change 100644 => 100755 piframefleet/root/etc/cont-init.d/30-config mode change 100644 => 100755 piframefleet/root/etc/services.d/_service_control/run create mode 100755 piframefleet/root/etc/services.d/syncthing/run mode change 100644 => 100755 piframefleet/root/etc/services.d/wireguard/run diff --git a/piframefleet/Dockerfile b/piframefleet/Dockerfile index 2475a17..1bb44a4 100644 --- a/piframefleet/Dockerfile +++ b/piframefleet/Dockerfile @@ -5,9 +5,6 @@ WORKDIR /opt/ # need to figure out if arm64/arm64 32bit multilib/arm COPY piframefleet/arch_detect.sh /opt/ -# Copy ansible samples -> /opt -COPY ansible /opt/ - # Install and base setup all the things RUN apk upgrade --update --no-cache && \ apk add python3 curl jq bash unzip && \ @@ -46,6 +43,7 @@ VOLUME /lib/modules ENV ENABLE_SYNCTHING=false EXPOSE 8384/tcp EXPOSE 22000/tcp +VOLUME /opt/syncthing # FileBrowser related 'stuff' ENV ENABLE_FILEBROWSER=false diff --git a/piframefleet/root/etc/cont-init.d/99-welcome b/piframefleet/root/etc/cont-init.d/00-welcome old mode 100644 new mode 100755 similarity index 100% rename from piframefleet/root/etc/cont-init.d/99-welcome rename to piframefleet/root/etc/cont-init.d/00-welcome diff --git a/piframefleet/root/etc/cont-init.d/30-config b/piframefleet/root/etc/cont-init.d/30-config old mode 100644 new mode 100755 index f97dfd4..b5d3b5f --- a/piframefleet/root/etc/cont-init.d/30-config +++ b/piframefleet/root/etc/cont-init.d/30-config @@ -1,9 +1,15 @@ #!/usr/bin/with-contenv bash +#################### +# Pictures storage +#################### +if [ ! -d "/opt/pictures" ] ; then + mkdir /opt/pictures +fi + #################### # WireGuard #################### - if [ "$ENABLE_WIREGUARD" = true ] ; then ip link del dev test 2>/dev/null if ip link add dev test type wireguard; then @@ -15,10 +21,22 @@ if [ "$ENABLE_WIREGUARD" = true ] ; then fi #################### -# Pictures storage +# syncthing #################### -if [ ! -d "/opt/pictures" ]; then - mkdir /opt/pictures +if [ "$ENABLE_SYNCTHING" = true ] ; then + if [ ! -d "/opt/syncthing" ]; then + mkdir /opt/syncthing + fi + ST_CONF="/opt/syncthing/config.xml" + if [ ! -f "$ST_CONF" ]; then + echo "**** Initial Syncthing Config ****" + /usr/bin/syncthing -generate /opt/syncthing + sed -i 's/
127.0.0.1:8384<\/address>/
0.0.0.0:8384<\/address>/g' /opt/syncthing/config.xml + sed -i 's///g' /opt/syncthing/config.xml + if [ -d "/root/Sync" ]; then + rm -r /root/Sync + fi + fi fi #################### diff --git a/piframefleet/root/etc/services.d/_service_control/run b/piframefleet/root/etc/services.d/_service_control/run old mode 100644 new mode 100755 diff --git a/piframefleet/root/etc/services.d/syncthing/run b/piframefleet/root/etc/services.d/syncthing/run new file mode 100755 index 0000000..de65091 --- /dev/null +++ b/piframefleet/root/etc/services.d/syncthing/run @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash + +if [ "$ENABLE_SYNCTHING" = false ] ; then + exit +fi + +/usr/bin/syncthing \ + -home="/opt/syncthing" \ + -no-browser diff --git a/piframefleet/root/etc/services.d/wireguard/run b/piframefleet/root/etc/services.d/wireguard/run old mode 100644 new mode 100755 diff --git a/piframefleet_run.sh b/piframefleet_run.sh index 12a7b76..23a7cae 100755 --- a/piframefleet_run.sh +++ b/piframefleet_run.sh @@ -13,14 +13,15 @@ sudo docker run -it \ --cap-add=NET_ADMIN \ --cap-add=SYS_MODULE \ -e TZ=UTC \ - -e ENABLE_WIREGUARD=true \ - -e ENABLE_SYNCTHING=false \ + -e ENABLE_WIREGUARD=false \ + -e ENABLE_SYNCTHING=true \ -e ENABLE_FILEBROWSER=true \ - -p 51820:51820/udp \ + -p 51821:51820/udp \ -p 8384:8384/tcp \ -p 22000:22000/tcp \ -p 9191:9191/tcp \ -v /lib/modules:/lib/modules:ro \ + -v /var/piframefleet/syncthing:/opt/syncthing \ -v /var/piframefleet/filebrowser:/opt/filebrowser \ -v /var/piframefleet/pictures:/opt/pictures \ piframe/piframefleet:latest