#!/bin/sh
#
# srestart - restart specified service
#

usage(){
  echo "Usage: srestart [SERVICE]..."
  echo "Restart the service specificed as argument, if the service"
  echo "has a service-file installed in /etc/rc.d/services/."
  echo
  echo "  -h, --help		print this help and exit"
  echo "  -v, --version		output version information and exit"
  echo
  echo "Report bugs to <johne@rootlinux.org>"
  exit 1
}

displayversion(){
  echo "srestart (rltools) 4.3"
  exit 0
}

if [ "$1" = "-h" -o "$1" = "--help" ]; then
  usage
fi

if [ "$1" = "-v" -o "$1" = "--version" ]; then
  displayversion
fi

if [ -z $1 ]; then
  echo "srestart: error: missing option"
  echo "Try 'srestart --help' for more information."
  exit 1
fi


if [ -f /etc/rc.d/services/$1.service ]; then
    /usr/sbin/sstop $1
    sleep 1
    /usr/sbin/sstart $1
    exit 0
  else
    echo "srestart: $1: no such service."
    exit 1
fi
