Skip to content

Commit 3a70f75

Browse files
authored
Merge pull request #346 from linuxserver/crontab-perms
Format cron init and set permissions
2 parents f5c2f5a + 28df27d commit 3a70f75

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
336336

337337
## Versions
338338

339+
* **02.03.23:** - Set permissions on crontabs during init.
339340
* **09.02.23:** - [Existing users should update:](https://github.com/linuxserver/docker-swag/blob/master/README.md#updating-configs) proxy.conf, authelia-location.conf and authelia-server.conf - Add Authentik configs, update Authelia configs.
340341
* **06.02.23:** - Add porkbun support back in.
341342
* **21.01.23:** - Unpin certbot version (allow certbot 2.x). !!BREAKING CHANGE!! We are temporarily removing the certbot porkbun plugin until a new version is released that is compatible with certbot 2.x.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ app_setup_block: |
154154
155155
# changelog
156156
changelogs:
157+
- { date: "02.03.23:", desc: "Set permissions on crontabs during init." }
157158
- { date: "09.02.23:", desc: "[Existing users should update:](https://github.com/linuxserver/docker-swag/blob/master/README.md#updating-configs) proxy.conf, authelia-location.conf and authelia-server.conf - Add Authentik configs, update Authelia configs." }
158159
- { date: "06.02.23:", desc: "Add porkbun support back in." }
159160
- { date: "21.01.23:", desc: "Unpin certbot version (allow certbot 2.x). !!BREAKING CHANGE!! We are temporarily removing the certbot porkbun plugin until a new version is released that is compatible with certbot 2.x." }
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
# if root crontabs do not exist in config
5-
# copy root crontab from system
6-
if [[ ! -f /config/crontabs/root ]] && crontab -l -u root; then
7-
crontab -l -u root >/config/crontabs/root
8-
fi
4+
# make folders
5+
mkdir -p \
6+
/config/crontabs
97

10-
# if root crontabs still do not exist in config (were not copied from system)
11-
# copy root crontab from included defaults
8+
## root
9+
# if crontabs do not exist in config
1210
if [[ ! -f /config/crontabs/root ]]; then
13-
cp /etc/crontabs/root /config/crontabs/
14-
fi
11+
# copy crontab from system
12+
if crontab -l -u root; then
13+
crontab -l -u root >/config/crontabs/root
14+
fi
1515

16-
# if abc crontabs do not exist in config
17-
# copy abc crontab from system
18-
if [[ ! -f /config/crontabs/abc ]] && crontab -l -u abc; then
19-
crontab -l -u abc >/config/crontabs/abc
16+
# if crontabs still do not exist in config (were not copied from system)
17+
# copy crontab from included defaults (using -n, do not overwrite an existing file)
18+
cp -n /etc/crontabs/root /config/crontabs/
2019
fi
20+
# set permissions and import user crontabs
21+
lsiown root:root /config/crontabs/root
22+
crontab -u root /config/crontabs/root
2123

22-
# if abc crontabs still do not exist in config (were not copied from system)
23-
# copy abc crontab from included defaults
24+
## abc
25+
# if crontabs do not exist in config
2426
if [[ ! -f /config/crontabs/abc ]]; then
25-
cp /etc/crontabs/abc /config/crontabs/
26-
fi
27+
# copy crontab from system
28+
if crontab -l -u abc; then
29+
crontab -l -u abc >/config/crontabs/abc
30+
fi
2731

28-
# import user crontabs
29-
crontab -u root /config/crontabs/root
32+
# if crontabs still do not exist in config (were not copied from system)
33+
# copy crontab from included defaults (using -n, do not overwrite an existing file)
34+
cp -n /etc/crontabs/abc /config/crontabs/
35+
fi
36+
# set permissions and import user crontabs
37+
lsiown abc:abc /config/crontabs/abc
3038
crontab -u abc /config/crontabs/abc

0 commit comments

Comments
 (0)