#!/bin/bash
# info: delete tulio autoupdate cron job
# options: NONE
#
# This function deletes tulio autoupdate cron job.

#----------------------------------------------------------#
#                Variables & Functions                     #
#----------------------------------------------------------#

# Includes
# shellcheck source=/etc/tuliocp/tulio.conf
source /etc/tuliocp/tulio.conf
# shellcheck source=/usr/local/tulio/func/main.sh
source $TULIO/func/main.sh
# load config file
source_conf "$TULIO/conf/tulio.conf"

#----------------------------------------------------------#
#                    Verifications                         #
#----------------------------------------------------------#

is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'

# Perform verification if read-only mode is enabled
check_tulio_demo_mode

#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

sed -i "/v-update-sys-tulio-all/d" "/var/spool/cron/crontabs/tulioweb"
sed -i "/v-update-sys-tulio-git/d" "/var/spool/cron/crontabs/tulioweb"

#----------------------------------------------------------#
#                       Tulio                             #
#----------------------------------------------------------#

# Restarting crond
$BIN/v-restart-cron
check_result $? "Cron restart failed" > /dev/null

# Logging
$BIN/v-log-action "system" "Warning" "System" "Automatic updates disabled."
log_event "$OK" "$ARGUMENTS"

exit
