Format shell scripts and set permissions

This commit is contained in:
Eric Nemchik
2023-03-02 19:18:53 +00:00
parent a614cef135
commit 826e0be29d
6 changed files with 57 additions and 46 deletions
@@ -1,8 +1,9 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
if [ ! -f /usr/sbin/cron ] && [ -f /usr/bin/apt ]; then
echo "**** Adding cron to package install list ****"
echo "cron" >> /mod-repo-packages-to-install.list
echo "cron" >>/mod-repo-packages-to-install.list
else
echo "**** cron package already installed, skipping ****"
fi
@@ -1,35 +1,38 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# make folders
mkdir -p \
/config/crontabs
# if root crontabs do not exist in config
## root
# if crontabs do not exist in config
if [[ ! -f /config/crontabs/root ]]; then
# copy root crontab from system
# copy crontab from system
if crontab -l -u root; then
crontab -l -u root > /config/crontabs/root
crontab -l -u root >/config/crontabs/root
fi
# if root crontabs still do not exist in config (were not copied from system)
# copy root crontab from included defaults (using -n, do not overwrite an existing file)
# if crontabs still do not exist in config (were not copied from system)
# copy crontab from included defaults (using -n, do not overwrite an existing file)
cp -n /defaults/crontabs-mod/root /config/crontabs/
fi
# set permissions and import user crontabs
lsiown root:root /config/crontabs/root
crontab -u root /config/crontabs/root
# if abc crontabs do not exist in config
## abc
# if crontabs do not exist in config
if [[ ! -f /config/crontabs/abc ]]; then
# copy abc crontab from system
# copy crontab from system
if crontab -l -u abc; then
crontab -l -u abc > /config/crontabs/abc
crontab -l -u abc >/config/crontabs/abc
fi
# if abc crontabs still do not exist in config (were not copied from system)
# copy abc crontab from included defaults
# if crontabs still do not exist in config (were not copied from system)
# copy crontab from included defaults (using -n, do not overwrite an existing file)
cp -n /defaults/crontabs-mod/abc /config/crontabs/
fi
# import user crontabs
crontab -u root /config/crontabs/root
# set permissions and import user crontabs
lsiown abc:abc /config/crontabs/abc
crontab -u abc /config/crontabs/abc
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
if [ -f /usr/bin/apt ]; then
# ubuntu