Skip to content

Commit 9a15dcc

Browse files
committed
universal: alpine-quieter-cron initial release
Make cron logging configurable and quieter: * Support env var CRON_LOG_LEVEL, which is passed to the crond implementation * Default to being quieter and briefly explain rationale
1 parent 71ed9ae commit 9a15dcc

File tree

22 files changed

+28
-109
lines changed

22 files changed

+28
-109
lines changed

Diff for: .github/workflows/BuildImage.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
env:
1313
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
1414
ENDPOINT: "linuxserver/mods" #don't modify
15-
BASEIMAGE: "replace_baseimage" #replace
16-
MODNAME: "replace_modname" #replace
15+
BASEIMAGE: "universal" #replace
16+
MODNAME: "alpine-quieter-cron" #replace
1717
MOD_VERSION: ${{ inputs.mod_version }} #don't modify
1818
MULTI_ARCH: "true" #set to false if not needed
1919

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
FROM scratch
44

5-
LABEL maintainer="username"
5+
LABEL maintainer="kenstir"
66

77
# copy local files
88
COPY root/ /

Diff for: Dockerfile.complex

-33
This file was deleted.

Diff for: README.md

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
# Rsync - Docker mod for openssh-server
1+
# alpine-quieter-cron - Docker mod for containers derived from docker-baseimage-alpine
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds the ability to control the busybox crond logging level during container start.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
6-
7-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
8-
9-
# Mod creation instructions
10-
11-
* Fork the repo, create a new branch based on the branch `template`.
12-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
13-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
14-
* After all init scripts and services are created, run `find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print -exec chmod +x {} +` to fix permissions.
15-
* Edit this readme with pertinent info, delete these instructions.
16-
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the vars for `BASEIMAGE` and `MODNAME`. Set the versioning logic and `MULTI_ARCH` if needed.
17-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
18-
* Submit PR against the branch created by the team.
19-
20-
21-
## Tips and tricks
22-
23-
* Some images have helpers built in, these images are currently:
24-
* [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files)
25-
* [Code-server](https://github.com/linuxserver/docker-code-server/pull/95)
5+
In docker arguments, set environment variables
6+
```
7+
DOCKER_MODS=kenstir/mods:alpine-quieter-cron
8+
CRON_LOG_LEVEL=7
9+
```

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/dependencies.d/init-mods

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/run

-30
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/type

-1
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/up

-1
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/dependencies.d/init-mods-package-install

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/run

-8
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/type

-1
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/up

-1
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mod-imagename-modname-install

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-imagename-modname-add-package

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/svc-cron/run

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
if builtin command -v crontab >/dev/null 2>&1 && [[ -n "$(crontab -l -u abc 2>/dev/null || true)" || -n "$(crontab -l -u root 2>/dev/null || true)" ]]; then
5+
if builtin command -v busybox >/dev/null 2>&1 && [[ $(busybox || true) =~ [[:space:]](crond)([,]|$) ]]; then
6+
# busybox crond logs every wakeup at level 5 which is noisy, use 7
7+
exec busybox crond -f -S -l ${CRON_LOG_LEVEL:-7}
8+
elif [[ -f /usr/bin/apt ]] && [[ -f /usr/sbin/cron ]]; then
9+
# Berkeley cron logs the start of all jobs at level 1. Levels are additive, see `man 8 cron`.
10+
exec /usr/sbin/cron -f -L ${CRON_LOG_LEVEL:-1}
11+
else
12+
echo "**** cron not found ****"
13+
sleep infinity
14+
fi
15+
else
16+
sleep infinity
17+
fi

Diff for: root/etc/s6-overlay/s6-rc.d/svc-cron/type

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
longrun

Diff for: root/etc/s6-overlay/s6-rc.d/svc-mod-imagename-modname/run

-7
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/svc-mod-imagename-modname/type

-1
This file was deleted.

Diff for: root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-imagename-modname-add-package

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-imagename-modname-install

Whitespace-only changes.

Diff for: root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-imagename-modname

Whitespace-only changes.

0 commit comments

Comments
 (0)