#!/bin/sh
### BEGIN INIT INFO
# Provides:          cloudbackup-updater
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Rackspace Cloud Backup Auto Updater
# Description:       Auto-updater for the Rackspace Cloud Backup agent
### END INIT INFO

NAME=cloudbackup-updater
DAEMON=/usr/bin/cloudbackup-updater
PIDFILE=/var/run/cloudbackup-updater.pid
LOG=/var/log/cloudbackup-updater.log

. /lib/lsb/init-functions

case "$1" in
start)
        log_daemon_msg "Starting $NAME" "$NAME"
        start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON -- --daemon -p $PIDFILE -l $LOG
        log_end_msg $?
        ;;
stop)
        log_daemon_msg "Stopping $NAME" "$NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE
        log_end_msg $?
        ;;
force-reload|restart)
        log_daemon_msg "Restarting $NAME" "$NAME"
        start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE
        start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON -- --daemon -p $PIDFILE -l $LOG
        log_end_msg $?
        ;;
status)
        status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
        ;;
*)      log_action_msg "Usage: /etc/init.d/cloudbackup-updater {start|stop|status|restart}"
        exit 2
        ;;
esac
exit 0
