#!/bin/bash
set -o errexit


if [[ $TUEFIND_FLAVOUR != "krimdok" ]]; then
    exit 0
fi

if [ -r /etc/debian_version ]; then # Ubuntu
    root_crontab=/var/spool/cron/crontabs/root
else # CentOS
    root_crontab=/var/spool/cron/root
fi

if [ -r "$root_crontab" ]; then
    sed --in-place '/^# END VUFIND AUTOGENERATED/i 0 1 1 * * "$BIN/update_print_issns_titles_online_ppns_and_online_issns_list.sh"' \
        $root_crontab
else
    echo 'i 0 1 1 * * "$BIN/update_print_issns_titles_online_ppns_and_online_issns_list.sh"' > "$root_crontab"
    echo '# END VUFIND AUTOGENERATED' >> "$root_crontab"
fi

#!/bin/bash
set -o errexit


if [[ $TUEFIND_FLAVOUR != "krimdok" ]]; then
    exit 0
fi

if [ -r /etc/debian_version ]; then # Ubuntu
    root_crontab=/var/spool/cron/crontabs/root
else # CentOS
    root_crontab=/var/spool/cron/root
fi

if [ -r "$root_crontab" ]; then
    if [ grep --quiet 'purge_old_data.py' "$root_crontab" ]; then
        sed --in-place '/purge_old_data.py/i 0 1 1 * * "$BIN/update_print_issns_titles_online_ppns_and_online_issns_list.sh" > "$LOG_DIR/update_print_issns_titles_online_ppns_and_online_issns_list.log" 2>&1' \
            $root_crontab
    else
        sed --in-place '/^# END VUFIND AUTOGENERATED/i 0 1 1 * * "$BIN/update_print_issns_titles_online_ppns_and_online_issns_list.sh" > "$LOG_DIR/update_print_issns_titles_online_ppns_and_online_issns_list.log" 2>&1' \
            $root_crontab
    fi
else
    echo 'i 0 1 1 * * "$BIN/update_print_issns_titles_online_ppns_and_online_issns_list.sh" > "$LOG_DIR/update_print_issns_titles_online_ppns_and_online_issns_list.log" 2>&1' > "$root_crontab"
    echo '# END VUFIND AUTOGENERATED' >> "$root_crontab"
fi

Insert into the correct position.
Insert into the correct position.
