Difference between revisions of "Talk:Add a custom service"

From SME Server
Jump to navigationJump to search
(Created page with "I'm not sure that the chkconfig command is required")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
I'm not sure that the chkconfig command is required
 
I'm not sure that the chkconfig command is required
 +
 +
I know, but I love to be centos compatible--[[User:Stephdl|Stephdl]] ([[User talk:Stephdl|talk]]) 22:22, 2 October 2015 (CEST)
 +
 +
another scrip, I need to do some tests on it --[[User:Stephdl|Stephdl]] ([[User talk:Stephdl|talk]]) 22:22, 2 October 2015 (CEST)
 +
 +
#!/bin/sh
 +
#
 +
# chkconfig: - 88 10
 +
# description: Start/Stop the RADICALE server daemon
 +
# Default-Start: 2 3 4 5
 +
# Default-Stop: 0 1 6
 +
#
 +
 +
# Source function library.
 +
. /etc/rc.d/init.d/functions
 +
 +
#set the software path to run
 +
SCRIPT=/usr/bin/radicale
 +
#set the path to the configuration if needed
 +
CONFIG=/etc/radicale/config
 +
#set the name of the software to launch
 +
prog=radicale
 +
#set the user who run the software
 +
user=radicale
 +
 +
#if you don't need to set configuration files
 +
#exec="$SCRIPT"
 +
exec="$SCRIPT -C $CONFIG"
 +
 +
 +
#set the the lockfile
 +
lockfile=/var/lock/subsys/$prog
 +
#set the pid path, /var/run/$prog/ must be writable by the user
 +
pidfile=/var/run/$prog/$prog.pid
 +
 +
#stop the script if the binary and configuration files are not found
 +
[ -f $SCRIPT ] || exit 0
 +
[ -f $CONFIG ] || exit 0
 +
 +
###don't change here
 +
RETVAL=0
 +
 +
case "$1" in
 +
start)
 +
      echo -n $"Starting $prog  server: "
 +
    daemon --user=$user --pidfile=$pidfile $exec 
 +
    RETVAL=$?
 +
    echo
 +
    [ $RETVAL -eq 0 ] && touch $lockfile
 +
    ln -s $pidfile /var/run/$prog.pid 2>/dev/null
 +
    status radicale
 +
    RETVAL=$?
 +
#sometime the signal-event hangs, therefore I redirect to /dev/null
 +
#      echo -n $"Starting $prog  server: "
 +
#  daemon --user=$user --pidfile=$pidfile $exec >/dev/null 2>&1
 +
#  status radicale
 +
#  RETVAL=$?
 +
#    [ $RETVAL -eq 0 ] && touch $lockfile
 +
#    ln -s $pidfile /var/run/$prog.pid 2>/dev/null
 +
      ;;
 +
stop)
 +
      echo -n $"Stopping $prog server: "
 +
      killproc $SCRIPT
 +
      RETVAL=$?
 +
      echo
 +
      [ $RETVAL -eq 0 ] && rm -f $lockfile
 +
      ;;
 +
status)
 +
      status radicale
 +
      RETVAL=$?
 +
      ;;
 +
restart)
 +
      $0 stop
 +
      sleep 3
 +
      $0 start
 +
      RETVAL=$?
 +
      ;;
 +
*)
 +
      echo $"Usage: $0 {start|stop|status|restart}"
 +
      exit 1
 +
esac
 +
 +
exit $RETVAL

Latest revision as of 23:50, 2 October 2015

I'm not sure that the chkconfig command is required

I know, but I love to be centos compatible--Stephdl (talk) 22:22, 2 October 2015 (CEST)

another scrip, I need to do some tests on it --Stephdl (talk) 22:22, 2 October 2015 (CEST)

#!/bin/sh
#
# chkconfig: - 88 10
# description: Start/Stop the RADICALE server daemon
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
#

# Source function library.
. /etc/rc.d/init.d/functions

#set the software path to run
SCRIPT=/usr/bin/radicale
#set the path to the configuration if needed
CONFIG=/etc/radicale/config
#set the name of the software to launch
prog=radicale
#set the user who run the software
user=radicale

#if you don't need to set configuration files
#exec="$SCRIPT"
exec="$SCRIPT -C $CONFIG"


#set the the lockfile
lockfile=/var/lock/subsys/$prog
#set the pid path, /var/run/$prog/ must be writable by the user
pidfile=/var/run/$prog/$prog.pid

#stop the script if the binary and configuration files are not found
[ -f $SCRIPT ] || exit 0
[ -f $CONFIG ] || exit 0

###don't change here
RETVAL=0

case "$1" in
start)
      echo -n $"Starting $prog  server: "
   daemon --user=$user --pidfile=$pidfile $exec  
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch $lockfile
   ln -s $pidfile /var/run/$prog.pid 2>/dev/null
   status radicale
   RETVAL=$?
#sometime the signal-event hangs, therefore I redirect to /dev/null
#       echo -n $"Starting $prog  server: "
#   daemon --user=$user --pidfile=$pidfile $exec >/dev/null 2>&1 
#   status radicale
#   RETVAL=$?
#    [ $RETVAL -eq 0 ] && touch $lockfile
#    ln -s $pidfile /var/run/$prog.pid 2>/dev/null 
     ;;
stop)
      echo -n $"Stopping $prog server: "
      killproc $SCRIPT
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f $lockfile
      ;;
status)
      status radicale
      RETVAL=$?
      ;;
restart)
      $0 stop
      sleep 3
      $0 start
      RETVAL=$?
      ;;
*)
      echo $"Usage: $0 {start|stop|status|restart}"
      exit 1
esac

exit $RETVAL