#!/bin/sh
#
# sstart - start specified service
#

usage(){
  echo "Usage: sstart [SERVICE]..."
  echo "Start 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 "sstart (rltools) #VERSION#"
  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 "sstart: error: missing option"
  echo "Try 'sstart --help' for more information."
  exit 1
fi


if [ -f /etc/rc.d/services/$1.service ]; then
    if [ -f /tmp/$1.stoplog ]; then
	rm -f /tmp/$1.stoplog
    fi
    /etc/rc.d/services/$1.service start >/tmp/$1.startlog
    exit 0
  else
    echo "sstart: $1: no such service."
    exit 1
fi
