From c7a8f29178b7c757b075af5168404d08e164d2af Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sun, 31 Jul 2022 16:46:19 +0100 Subject: [PATCH 1/7] Update readme and example init --- README.md | 115 ++++++++++++++++-- root/etc/cont-init.d/98-vpn-config | 7 +- .../dependencies.d/init-mods-universal-sshvpn | 0 .../dependencies.d/init-mods-universal-sshvpn | 0 .../dependencies.d/init-mods | 0 .../s6-rc.d/init-mods-universal-sshvpn/run | 25 ++++ .../s6-rc.d/init-mods-universal-sshvpn/type | 1 + .../s6-rc.d/init-mods-universal-sshvpn/up | 1 + .../dependencies.d/init-services | 0 .../s6-rc.d/svc-mods-universal-sshvpn/run | 3 + .../s6-rc.d/svc-mods-universal-sshvpn/type | 1 + .../contents.d/init-mods-universal-sshvpn | 0 .../user/contents.d/svc-mods-universal-sshvpn | 0 root/etc/services.d/sshvpn/run | 0 14 files changed, 138 insertions(+), 15 deletions(-) create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-universal-sshvpn create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods-universal-sshvpn create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/dependencies.d/init-mods create mode 100755 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/dependencies.d/init-services create mode 100755 root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mods-universal-sshvpn create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mods-universal-sshvpn mode change 100644 => 100755 root/etc/services.d/sshvpn/run diff --git a/README.md b/README.md index 659a5c9..4afddd3 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ In this repository we will be going over two basic methods of making a Mod along One of the core ideas to remember when creating a Mod is that it can only contain a single image layer, the examples below will show you how to add files standardly and how to run complex logic to assemble the files in a build layer to copy them over into this single layer. +### Mod Types + +We now support "hybrid" mods, targeting both s6 v2 and v3. All currently supported Linuxserver base images are using s6 v3, however, older pinned images, forked versions, etc. may still be using v2. To support both cases, simply include both sets of files (as below) in your mod, the built-in mod logic will pick the appropriate files to run. v2 mods will run on v3 base images for the forseeable future but we will not provide support for that configuration. + ### Docker Mod Simple - just add scripts In this repository you will find the `Dockerfile` containing: @@ -70,12 +74,103 @@ COPY root/ / For most users this will suffice and anything in the root/ folder of the repository will be added to the end users Docker container / path. -The most common paths to leverage for Linuxserver images will be: +#### Legacy (v2) mods + +The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: + +```text +. +└── root + └── etc + ├── cont-init.d + │ ├── 95-apt-get + │ └── 98-universal-mymod -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x` and is run ordered by filename. + └── services.d + └── mymod + └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. +``` * root/etc/cont-init.d/<98-script-name> - Contains init logic scripts that run before the services in the container start these should exit 0 and are ordered by filename -* root/etc/services.d/`yourservice`/run - Contains scripts that run in the foreground for persistent services IE NGINX +* root/etc/services.d/yourservice/run - Contains scripts that run in the foreground for persistent services IE NGINX * root/defaults - Contains base config files that are copied/modified on first spinup +#### New (v3) mods + +The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: + +```text +. +└── root + └── etc + └── s6-overlay + └── s6-rc.d + ├── init-mods-end + │ └── dependencies.d + │ └── init-mods-universal-mymod + ├── init-mods-package-install + │ └── dependencies.d + │ └── init-mods-universal-mymod + ├── init-mods-universal-mymod + │ ├── dependencies.d + │ │ └── init-mods + │ ├── run -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x`. + │ ├── type -- This should container the string `oneshot`. + │ └── up -- This should contain the absolute path to `run` e.g. `/etc/s6-overlay/s6-rc.d/init-mods-universal-mymod/run`. + ├── svc-mods-universal-mymod + │ ├── dependencies.d + │ │ └── init-services + │ ├── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. + │ └── type -- This should contain the string `longrun`. + └── user + └── contents.d + ├── init-mods-universal-mymod + └── svc-mods-universal-mymod +``` + +Note: For `oneshot` scripts you can alternatively omit the `run` file entirely and use the [execlineb](https://skarnet.org/software/execline/execlineb.html) syntax in `up` if your requirements are simple enough. + +#### Installing Packages + +v3 mods make use of a single package install process for all mods to minimise the amount of calls to external endpoints and speed up the mod init process. If you need to install repo packages you should append them to `/mod-repo-packages-to-install.list` for repo packages or `/mod-pip-packages-to-install.list` for pip packages and the mod handler will install them for you. Make sure to handle both Ubuntu and Alpine package names if your mod needs to support both e.g. + +```bash +#!/usr/bin/with-contenv bash + +## Ubuntu +if [ -f /usr/bin/apt ]; then + echo "\ + dnsutils \ + net-tools \ + iputils-ping \ + traceroute" >> /mod-repo-packages-to-install.list + +fi +# Alpine +if [ -f /sbin/apk ]; then + echo "\ + bind-tools \ + net-tools" >> /mod-repo-packages-to-install.list +fi +``` + +If your mod needs to take additional config steps *after* the packages have been installed, add a second `oneshot` script and make it depend on `init-mods-package-install` e.g. + +```text +. +└── root + └── etc + └── s6-overlay + └── s6-rc.d + └── init-mods-universal-mymod-postinstall + ├── dependencies.d + │ └── init-mods-package-install + ├── run + ├── type + └── up +``` + +Services will always run last, controlled by their dependency on `init-services`. + The example files in this repo contain a script to install sshutil and a service file to run the installed utility. ### Docker Mod Complex - Sky is the limit @@ -87,14 +182,14 @@ In this repository you will find the `Dockerfile.complex` containing: FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl && \ - echo "**** grab rclone ****" && \ - mkdir -p /root-layer && \ - curl -o \ - /root-layer/rclone.deb -L \ - "https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb" + echo "**** install packages ****" && \ + apk add --no-cache \ + curl && \ + echo "**** grab rclone ****" && \ + mkdir -p /root-layer && \ + curl -o \ + /root-layer/rclone.deb -L \ + "https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb" # copy local files COPY root/ /root-layer/ diff --git a/root/etc/cont-init.d/98-vpn-config b/root/etc/cont-init.d/98-vpn-config index a5f9127..93f1382 100644 --- a/root/etc/cont-init.d/98-vpn-config +++ b/root/etc/cont-init.d/98-vpn-config @@ -1,8 +1,6 @@ #!/usr/bin/with-contenv bash -# Determine if setup is needed -if [ ! -f /usr/local/lib/python***/dist-packages/sshuttle ] && \ -[ -f /usr/bin/apt ]; then +if [ -f /usr/bin/apt ]; then ## Ubuntu apt-get update apt-get install --no-install-recommends -y \ @@ -12,8 +10,7 @@ if [ ! -f /usr/local/lib/python***/dist-packages/sshuttle ] && \ python3-pip pip3 install sshuttle fi -if [ ! -f /usr/lib/python***/site-packages/sshuttle ] && \ -[ -f /sbin/apk ]; then +if [ -f /sbin/apk ]; then # Alpine apk add --no-cache \ iptables \ diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-universal-sshvpn new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods-universal-sshvpn new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/dependencies.d/init-mods new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run new file mode 100755 index 0000000..dd7b5f9 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash + +if [ -f /usr/bin/apt ]; then + ## Ubuntu + echo "\ + iptables \ + openssh-client \ + python3 \ + python3-pip" >> /mod-repo-packages-to-install.list +fi + +if [ -f /sbin/apk ]; then + # Alpine + echo "\ + iptables \ + openssh \ + python3 \ + py3-pip" >> /mod-repo-packages-to-install.list +fi + +echo "\ + sshuttle" >> /mod-pip-packages-to-install.list + +chown -R root:root /root +chmod -R 600 /root/.ssh diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up new file mode 100644 index 0000000..3490304 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run b/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run new file mode 100755 index 0000000..7d49e79 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash + +sshuttle --dns --remote root@${HOST}:${PORT} 0/0 -x 172.17.0.0/16 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type b/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mods-universal-sshvpn new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mods-universal-sshvpn new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/services.d/sshvpn/run b/root/etc/services.d/sshvpn/run old mode 100644 new mode 100755 From f41df9621f35c01755fffe55c881874876d8ee4c Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sun, 31 Jul 2022 21:01:01 +0100 Subject: [PATCH 2/7] Add note about defaults --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4afddd3..1dec98f 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin ```text . └── root + ├── defaults -- Any default config files you need to copy as part of the mod can be placed here └── etc ├── cont-init.d │ ├── 95-apt-get @@ -90,10 +91,6 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. ``` -* root/etc/cont-init.d/<98-script-name> - Contains init logic scripts that run before the services in the container start these should exit 0 and are ordered by filename -* root/etc/services.d/yourservice/run - Contains scripts that run in the foreground for persistent services IE NGINX -* root/defaults - Contains base config files that are copied/modified on first spinup - #### New (v3) mods The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: @@ -101,6 +98,7 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin ```text . └── root + ├── defaults -- Any default config files you need to copy as part of the mod can be placed here └── etc └── s6-overlay └── s6-rc.d From 1c70f4f11f70dbdfd9ad5da3519369eec978be02 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Mon, 1 Aug 2022 14:53:53 +0100 Subject: [PATCH 3/7] Fix mod/mods naming --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1dec98f..04251a6 100644 --- a/README.md +++ b/README.md @@ -104,25 +104,25 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin └── s6-rc.d ├── init-mods-end │ └── dependencies.d - │ └── init-mods-universal-mymod + │ └── init-mod-universal-mymod ├── init-mods-package-install │ └── dependencies.d - │ └── init-mods-universal-mymod - ├── init-mods-universal-mymod + │ └── init-mod-universal-mymod + ├── init-mod-universal-mymod │ ├── dependencies.d │ │ └── init-mods │ ├── run -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x`. │ ├── type -- This should container the string `oneshot`. - │ └── up -- This should contain the absolute path to `run` e.g. `/etc/s6-overlay/s6-rc.d/init-mods-universal-mymod/run`. - ├── svc-mods-universal-mymod + │ └── up -- This should contain the absolute path to `run` e.g. `/etc/s6-overlay/s6-rc.d/init-mod-universal-mymod/run`. + ├── svc-mod-universal-mymod │ ├── dependencies.d │ │ └── init-services │ ├── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. │ └── type -- This should contain the string `longrun`. └── user └── contents.d - ├── init-mods-universal-mymod - └── svc-mods-universal-mymod + ├── init-mod-universal-mymod + └── svc-mod-universal-mymod ``` Note: For `oneshot` scripts you can alternatively omit the `run` file entirely and use the [execlineb](https://skarnet.org/software/execline/execlineb.html) syntax in `up` if your requirements are simple enough. @@ -159,7 +159,7 @@ If your mod needs to take additional config steps *after* the packages have been └── etc └── s6-overlay └── s6-rc.d - └── init-mods-universal-mymod-postinstall + └── init-mod-universal-mymod-postinstall ├── dependencies.d │ └── init-mods-package-install ├── run From 79c22dabaa6b0083749d638fc853cb3c140a6fb0 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Mon, 1 Aug 2022 14:55:36 +0100 Subject: [PATCH 4/7] Fix mod/mods naming on example mod --- .../dependencies.d/init-mods | 0 .../run | 0 .../type | 0 root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/up | 1 + .../{init-mods-universal-sshvpn => init-mod-universal-sshvpn} | 0 .../{init-mods-universal-sshvpn => init-mod-universal-sshvpn} | 0 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up | 1 - .../dependencies.d/init-services | 0 .../{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn}/run | 0 .../{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn}/type | 0 .../{init-mods-universal-sshvpn => init-mod-universal-sshvpn} | 0 .../{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn} | 0 12 files changed, 1 insertion(+), 1 deletion(-) rename root/etc/s6-overlay/s6-rc.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn}/dependencies.d/init-mods (100%) rename root/etc/s6-overlay/s6-rc.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn}/run (100%) rename root/etc/s6-overlay/s6-rc.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn}/type (100%) create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/up rename root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn} (100%) rename root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn} (100%) delete mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up rename root/etc/s6-overlay/s6-rc.d/{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn}/dependencies.d/init-services (100%) rename root/etc/s6-overlay/s6-rc.d/{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn}/run (100%) rename root/etc/s6-overlay/s6-rc.d/{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn}/type (100%) rename root/etc/s6-overlay/s6-rc.d/user/contents.d/{init-mods-universal-sshvpn => init-mod-universal-sshvpn} (100%) rename root/etc/s6-overlay/s6-rc.d/user/contents.d/{svc-mods-universal-sshvpn => svc-mod-universal-sshvpn} (100%) diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/dependencies.d/init-mods similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/dependencies.d/init-mods rename to root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/dependencies.d/init-mods diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run b/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/run similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run rename to root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type b/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/type similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/type rename to root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/type diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/up b/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/up new file mode 100644 index 0000000..51966eb --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mod-universal-sshvpn/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-universal-sshvpn similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-universal-sshvpn rename to root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-universal-sshvpn diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-universal-sshvpn similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods-universal-sshvpn rename to root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-universal-sshvpn diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up b/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up deleted file mode 100644 index 3490304..0000000 --- a/root/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/s6-rc.d/init-mods-universal-sshvpn/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/dependencies.d/init-services similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/dependencies.d/init-services rename to root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/dependencies.d/init-services diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run b/root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/run similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/run rename to root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type b/root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/type similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/svc-mods-universal-sshvpn/type rename to root/etc/s6-overlay/s6-rc.d/svc-mod-universal-sshvpn/type diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-universal-sshvpn similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mods-universal-sshvpn rename to root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-universal-sshvpn diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mods-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-universal-sshvpn similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mods-universal-sshvpn rename to root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-universal-sshvpn From dc72e9088a5370b3970c0b7ba3814573becb6dc6 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sat, 27 Aug 2022 11:16:22 +0100 Subject: [PATCH 5/7] Improve clarity and formatting --- README.md | 89 ++++++++++--------- .../dependencies.d/init-mod-universal-sshvpn | 0 2 files changed, 46 insertions(+), 43 deletions(-) delete mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-universal-sshvpn diff --git a/README.md b/README.md index 04251a6..1cb2b31 100644 --- a/README.md +++ b/README.md @@ -81,14 +81,14 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin ```text . └── root - ├── defaults -- Any default config files you need to copy as part of the mod can be placed here - └── etc - ├── cont-init.d - │ ├── 95-apt-get - │ └── 98-universal-mymod -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x` and is run ordered by filename. - └── services.d - └── mymod - └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. + ├── defaults -- Any default config files you need to copy as part of the mod can be placed here + └── etc + ├── cont-init.d + │ ├── 95-apt-get + │ └── 98-universal-mymod -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x` and is run ordered by filename. + └── services.d + └── mymod + └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. ``` #### New (v3) mods @@ -98,31 +98,31 @@ The most common paths to leverage for Linuxserver images are as follows. Assumin ```text . └── root - ├── defaults -- Any default config files you need to copy as part of the mod can be placed here - └── etc - └── s6-overlay - └── s6-rc.d - ├── init-mods-end - │ └── dependencies.d - │ └── init-mod-universal-mymod - ├── init-mods-package-install - │ └── dependencies.d - │ └── init-mod-universal-mymod - ├── init-mod-universal-mymod - │ ├── dependencies.d - │ │ └── init-mods - │ ├── run -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x`. - │ ├── type -- This should container the string `oneshot`. - │ └── up -- This should contain the absolute path to `run` e.g. `/etc/s6-overlay/s6-rc.d/init-mod-universal-mymod/run`. - ├── svc-mod-universal-mymod - │ ├── dependencies.d - │ │ └── init-services - │ ├── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. - │ └── type -- This should contain the string `longrun`. - └── user - └── contents.d - ├── init-mod-universal-mymod - └── svc-mod-universal-mymod + ├── defaults -- Any default config files you need to copy as part of the mod can be placed here + └── etc + └── s6-overlay + └── s6-rc.d + ├── init-mods-end + │ └── dependencies.d + │ └── init-mod-universal-mymod -- If your mod does not need to install packages it should be a dependency of init-mods-end + ├── init-mods-package-install + │ └── dependencies.d + │ └── init-mod-universal-mymod -- If your mod needs to install packages it should be a dependency of init-mods-package-install + ├── init-mod-universal-mymod + │ ├── dependencies.d + │ │ └── init-mods + │ ├── run -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x`. + │ ├── type -- This should contain the string `oneshot`. + │ └── up -- This should contain the absolute path to `run` e.g. `/etc/s6-overlay/s6-rc.d/init-mod-universal-mymod/run`. + ├── svc-mod-universal-mymod + │ ├── dependencies.d + │ │ └── init-services + │ ├── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. + │ └── type -- This should contain the string `longrun`. + └── user + └── contents.d + ├── init-mod-universal-mymod + └── svc-mod-universal-mymod ``` Note: For `oneshot` scripts you can alternatively omit the `run` file entirely and use the [execlineb](https://skarnet.org/software/execline/execlineb.html) syntax in `up` if your requirements are simple enough. @@ -151,20 +151,23 @@ if [ -f /sbin/apk ]; then fi ``` -If your mod needs to take additional config steps *after* the packages have been installed, add a second `oneshot` script and make it depend on `init-mods-package-install` e.g. +If your mod needs to take additional config steps *after* the packages have been installed, add a second `oneshot` script and make it depend on `init-mods-package-install` and add it as a dependency of `init-mods-end` e.g. ```text . └── root - └── etc - └── s6-overlay - └── s6-rc.d - └── init-mod-universal-mymod-postinstall - ├── dependencies.d - │ └── init-mods-package-install - ├── run - ├── type - └── up + └── etc + └── s6-overlay + └── s6-rc.d + ├── init-mods-end + │ └── dependencies.d + │ └── init-mod-universal-mymod-postinstall + └── init-mod-universal-mymod-postinstall + ├── dependencies.d + │ └── init-mods-package-install + ├── run + ├── type + └── up ``` Services will always run last, controlled by their dependency on `init-services`. diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-universal-sshvpn b/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-universal-sshvpn deleted file mode 100644 index e69de29..0000000 From 46aa3a3f861213ddbcc6f2b9cbe64cad9190405d Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sat, 27 Aug 2022 15:47:35 +0100 Subject: [PATCH 6/7] Swap v2 and v3 sections. --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1cb2b31..a61bc10 100644 --- a/README.md +++ b/README.md @@ -74,23 +74,6 @@ COPY root/ / For most users this will suffice and anything in the root/ folder of the repository will be added to the end users Docker container / path. -#### Legacy (v2) mods - -The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: - -```text -. -└── root - ├── defaults -- Any default config files you need to copy as part of the mod can be placed here - └── etc - ├── cont-init.d - │ ├── 95-apt-get - │ └── 98-universal-mymod -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x` and is run ordered by filename. - └── services.d - └── mymod - └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. -``` - #### New (v3) mods The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: @@ -172,6 +155,23 @@ If your mod needs to take additional config steps *after* the packages have been Services will always run last, controlled by their dependency on `init-services`. +#### Legacy (v2) mods + +The most common paths to leverage for Linuxserver images are as follows. Assuming a mod name of `universal-mymod`: + +```text +. +└── root + ├── defaults -- Any default config files you need to copy as part of the mod can be placed here + └── etc + ├── cont-init.d + │ ├── 95-apt-get + │ └── 98-universal-mymod -- This is the init logic script that runs before the services in the container. It needs to be `chmod +x` and is run ordered by filename. + └── services.d + └── mymod + └── run -- This is the script that runs in the foreground for persistent services. It needs to be `chmod +x`. +``` + The example files in this repo contain a script to install sshutil and a service file to run the installed utility. ### Docker Mod Complex - Sky is the limit From ce40db36a9c62647c64152284609ba2a3ff7b98e Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sat, 27 Aug 2022 15:49:45 +0100 Subject: [PATCH 7/7] Add user bundle to additional v3 section. --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a61bc10..cfb7d96 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ if [ -f /sbin/apk ]; then fi ``` -If your mod needs to take additional config steps *after* the packages have been installed, add a second `oneshot` script and make it depend on `init-mods-package-install` and add it as a dependency of `init-mods-end` e.g. +If your mod needs to take additional config steps *after* the packages have been installed, add a second `oneshot` script and make it depend on `init-mods-package-install`, add it as a dependency of `init-mods-end`, and add it to the content bundle e.g. ```text . @@ -145,12 +145,15 @@ If your mod needs to take additional config steps *after* the packages have been ├── init-mods-end │ └── dependencies.d │ └── init-mod-universal-mymod-postinstall - └── init-mod-universal-mymod-postinstall - ├── dependencies.d - │ └── init-mods-package-install - ├── run - ├── type - └── up + ├── init-mod-universal-mymod-postinstall + │ ├── dependencies.d + │ │ └── init-mods-package-install + │ ├── run + │ ├── type + │ └── up + └── user + └── contents.d + └── init-mod-universal-mymod-postinstall ``` Services will always run last, controlled by their dependency on `init-services`.