#! /bin/bash
#
# Author: Uwe Teutsch-von Winckler
#
# /etc/init.d/monit_os_update
#
### BEGIN INIT INFO
# Provides: monit_os_update
# Required-Start: $syslog $local_fs $network $named $time
# Required-Stop:  $syslog $local_fs $network $named $time
# Default-Start:  3 4 5
# Default-Stop:   0 1 2 6
# Short-Description: monitoring_of_sg_os_update
# Description: monitoring of the sg os update state after reboot
### END INIT INFO

export PATH=/usr/bin:/bin:$PATH
export RPM_INSTALL_PREFIX=/opt

. /etc/rc.status

rc_reset

case "$1" in
    start)
        logger -t monit_os_update "received service command: $1"
        nice -n $((10 - `nice`)) ionice -c 3 /opt/soco-common/check_os_update_state.sh
        rc_status -v
        logger -t monit_os_update "exiting service command: $1 (rc=$_rc_status)"
        ;;
    stop)
        logger -t monit_os_update "received service command: $1"
        echo -n "Stopping monit_os_update not supported"
        rc_failed 0
        rc_status -v
        logger -t monit_os_update "exiting service command: $1 (rc=$_rc_status)"
        ;;
    restart|force-reload)
        logger -t monit_os_update "received service command: $1"
        echo -n "restarting monit_os_update not supported"
        rc_failed 0
        rc_status -v
        logger -t monit_os_update "exiting service command: $1 (rc=$_rc_status)"
        ;;
    try-restart|reload)
        logger -t monit_os_update "received service command: $1"
        echo -n "try-restarting monit_os_update not supported"
        rc_failed 0
        rc_status -v
        logger -t monit_os_update "exiting service command: $1 (rc=$_rc_status)"
        ;;
    status)
        echo -n "Checking the status of monit_os_update not supported "
        rc_failed 0
        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload|force-reload}"
        logger -t monit_os_update "wrong usage of service (rc=1)"
        exit 1
        ;;
esac

# Set exit status
rc_exit
