Пишем свой скрипт для service (на примере openldap)


/etc/init.d/openldap
function start()
{
  if [ $(ps -A |grep -w slapd|wc -l) -eq 1 ]; then
  {
    echo "Openldap it is already started";
  }
  else
  {
    /opt/openldap/libexec/slapd;
   if [ $(ps -A |grep -w slapd|wc -l) -eq 1 ]; then
   {
    echo "Openldap start .......................................... [OK]";
   }
   else
   {
    echo "Openldap start .......................................... [FATAL]";
   }
   fi
  }
  fi
}
function stop()
{
   if [ $(ps -A |grep -w slapd|wc -l) -eq 0 ]; then
  {
    echo "Openldap it is already stopped";
  }
  else
  {
   killall -SIGKILL slapd;
   if [ $(ps -A |grep -w slapd|wc -l) -eq 0 ]; then
   {
    echo "Openldap stop ........................................... [OK]";
   }
   else
   {
    echo "Openldap stop .......................................... [FATAL]";
   }
   fi
  }
  fi

}
function restart()
{
  stop;
  start;
}

function test()
{
 /opt/openldap/sbin/slaptest;
}

case $1 in
  start )
     start;
   ;;
  stop )
     stop;
   ;;
  restart )
     stop;
     start;
   ;;
  test )
     test;
   ;;
 esac


Поесню немного:


Проверяем:

[root@lora openldap]# service openldap restart
Openldap stop ........................................... [OK]
Openldap start .......................................... [OK]