#! /bin/sh
# Copyright (c) 2011 SUSE
# All rights reserved.
#
# Author: Robert Schweikert
#
# /etc/init.d/cloudinfo
#
### BEGIN INIT INFO
# Provides:       cloudinfo
# Required-Start: $remote_fs $syslog $network
# Required-Stop:  $remote_fs $syslog
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: Information service for cloud nodes
# Description: Information service to allow cloud nodes to configure themselves
### END INIT INFO

# First reset status of this service
. /etc/rc.status
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

SERVICE_BIN="/sbin/suseNebulaConfSrv"
SERVICE_PID="${CHROOT_PREFIX}/var/run/suseNebula/infoSrv.pid"

case "$1" in
  start)
    echo -n "Starting cloud info service: "
    $SERVICE_BIN &
    rc_status -v
  ;;
  stop)
    echo -n "Stopping cloud info service: "
    pid=`cat ${SERVICE_PID}`
    kill -TERM $pid
    #killproc does not work, it insists that $SERVICE_BIN does not exist
    # Suspect this has something to do with it being python
    #killproc -p ${SERVICE_PID} -TERM $SERVICE_BIN
    # Remember status and be quiet
    rc_status -v
  ;;
  restart)
    $0 stop
    $0 start $2
    rc_status
  ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
  ;;
esac
rc_exit


