[DOCKER] Build cron into the container
This commit is contained in:
parent
8d992cbcab
commit
fadb862b8a
8 changed files with 55 additions and 50 deletions
|
|
@ -57,6 +57,10 @@ RUN mkdir -p /config && \
|
|||
# CONTAINER CONFIGS
|
||||
|
||||
ENV EDITOR="nano" \
|
||||
HOME="/config"
|
||||
HOME="/config" \
|
||||
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
|
||||
DEFAULT_WORKSPACE=/config \
|
||||
CRON_SCRIPT="/config/cron" \
|
||||
LOGS_TO_STDOUT=/config/.cron.log
|
||||
|
||||
VOLUME /config
|
||||
|
|
@ -79,11 +79,11 @@ RUN mkdir -p /config && \
|
|||
###############################################################################
|
||||
# CONTAINER CONFIGS
|
||||
|
||||
|
||||
ENV YTDL_SUB_TYPE="gui" \
|
||||
EDITOR="nano" \
|
||||
ENV EDITOR="nano" \
|
||||
HOME="/config" \
|
||||
DOCKER_MODS=linuxserver/mods:universal-cron \
|
||||
DEFAULT_WORKSPACE=/config/ytdl-sub-configs
|
||||
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
|
||||
DEFAULT_WORKSPACE=/config/ytdl-sub-configs \
|
||||
CRON_SCRIPT="/config/ytdl-sub-configs/cron" \
|
||||
LOGS_TO_STDOUT=/config/ytdl-sub-configs/.cron.log
|
||||
|
||||
VOLUME /config
|
||||
|
|
@ -83,6 +83,10 @@ RUN mkdir -p /config && \
|
|||
# CONTAINER CONFIGS
|
||||
|
||||
ENV EDITOR="nano" \
|
||||
HOME="/config"
|
||||
HOME="/config" \
|
||||
DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \
|
||||
DEFAULT_WORKSPACE=/config \
|
||||
CRON_SCRIPT="/config/cron" \
|
||||
LOGS_TO_STDOUT=/config/.cron.log
|
||||
|
||||
VOLUME /config
|
||||
32
docker/root/custom-cont-init.d/defaults
Normal file
32
docker/root/custom-cont-init.d/defaults
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
echo "Starting ytdl-sub..."
|
||||
|
||||
# copy config
|
||||
[[ ! -e "$DEFAULT_WORKSPACE/config.yaml" ]] && \
|
||||
mkdir -p "$DEFAULT_WORKSPACE" && \
|
||||
cp /defaults/config.yaml "$DEFAULT_WORKSPACE/config.yaml"
|
||||
[[ ! -e "$DEFAULT_WORKSPACE/subscriptions.yaml" ]] && \
|
||||
mkdir -p "$DEFAULT_WORKSPACE" && \
|
||||
cp /defaults/subscriptions.yaml "$DEFAULT_WORKSPACE/subscriptions.yaml"
|
||||
[[ ! -d "$DEFAULT_WORKSPACE/examples" ]] && \
|
||||
mkdir -p "$DEFAULT_WORKSPACE/examples" && \
|
||||
cp /defaults/examples/* "$DEFAULT_WORKSPACE/examples"
|
||||
|
||||
# permissions
|
||||
chown -R ${PUID:-abc}:${PGID:-abc} \
|
||||
/config
|
||||
|
||||
# set up cron
|
||||
if [ "$CRON_SCHEDULE" != "" ] ; then
|
||||
[[ ! -e "$CRON_SCRIPT" ]] && \
|
||||
cp /defaults/cron "$CRON_SCRIPT"
|
||||
|
||||
cp /defaults/cron_wrapper "$DEFAULT_WORKSPACE/.cron_wrapper"
|
||||
|
||||
echo "# min hour day month weekday command" > /config/crontabs/abc
|
||||
echo "$CRON_SCHEDULE $DEFAULT_WORKSPACE/.cron_wrapper" >> /config/crontabs/abc
|
||||
|
||||
chmod +x "$CRON_SCRIPT"
|
||||
chown abc:abc "$CRON_SCRIPT"
|
||||
fi
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# Exit if not gui
|
||||
if [ "$YTDL_SUB_TYPE" != "gui" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Checking ytdl-sub-gui defaults..."
|
||||
|
||||
# copy config
|
||||
[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \
|
||||
mkdir -p /config/ytdl-sub-configs && \
|
||||
cp /defaults/config.yaml /config/ytdl-sub-configs/config.yaml
|
||||
[[ ! -e /config/ytdl-sub-configs/subscriptions.yaml ]] && \
|
||||
mkdir -p /config/ytdl-sub-configs && \
|
||||
cp /defaults/subscriptions.yaml /config/ytdl-sub-configs/subscriptions.yaml
|
||||
[[ ! -d /config/ytdl-sub-configs/examples ]] && \
|
||||
mkdir -p /config/ytdl-sub-configs/examples && \
|
||||
cp /defaults/examples/* /config/ytdl-sub-configs/examples
|
||||
|
||||
# permissions
|
||||
chown -R ${PUID:-abc}:${PGID:-abc} \
|
||||
/config
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# Exit if gui
|
||||
if [ "$YTDL_SUB_TYPE" == "gui" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Checking ytdl-sub defaults..."
|
||||
|
||||
# copy config
|
||||
[[ ! -e /config/config.yaml ]] && \
|
||||
cp /defaults/config.yaml /config/config.yaml
|
||||
[[ ! -e /config/subscriptions.yaml ]] && \
|
||||
cp /defaults/subscriptions.yaml /config/subscriptions.yaml
|
||||
[[ ! -d /config/examples ]] && \
|
||||
cp -R /defaults/examples /config/
|
||||
|
||||
# permissions
|
||||
chown -R ${PUID:-abc}:${PGID:-abc} \
|
||||
/config
|
||||
4
docker/root/defaults/cron
Normal file
4
docker/root/defaults/cron
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
echo "Beginning cron job..."
|
||||
|
||||
# Place your ytdl-sub command here
|
||||
# ytdl-sub -h
|
||||
4
docker/root/defaults/cron_wrapper
Normal file
4
docker/root/defaults/cron_wrapper
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
. "$CRON_SCRIPT" | tee "$LOGS_TO_STDOUT"
|
||||
Loading…
Reference in a new issue