#!/sbin/openrc-run # Copyright 2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 description="Daily Telegram channel regeneration with tg2zola" supervisor="supervise-daemon" command="/usr/libexec/tg2zola/tg2zola-sync" command_args="--daemon" command_user="tg2zola:tg2zola" directory="/var/lib/tg2zola" output_log="/var/log/tg2zola.log" error_log="/var/log/tg2zola.log" respawn_delay=60 respawn_max=0 extra_commands="sync" description_sync="Run one immediate channel regeneration cycle" depend() { need net } _load_config() { if [ ! -r /etc/tg2zola/tg2zola.conf ]; then eerror "Missing /etc/tg2zola/tg2zola.conf" return 1 fi CHANNELS="" OUTPUT_DIR="/var/lib/tg2zola" # shellcheck disable=SC1091 . /etc/tg2zola/tg2zola.conf if [ -z "${CHANNELS}" ]; then eerror "Set CHANNELS in /etc/tg2zola/tg2zola.conf" return 1 fi } start_pre() { _load_config || return 1 checkpath -d -m 0750 -o tg2zola:tg2zola /var/lib/tg2zola "${OUTPUT_DIR}" checkpath -f -m 0640 -o tg2zola:tg2zola "${output_log}" } sync() { _load_config || return 1 checkpath -d -m 0750 -o tg2zola:tg2zola /var/lib/tg2zola "${OUTPUT_DIR}" ebegin "Regenerating Telegram channels with tg2zola" start-stop-daemon --start --user tg2zola:tg2zola --chdir /var/lib/tg2zola \ --exec /usr/libexec/tg2zola/tg2zola-sync eend $? }