[Kimchi-devel] CentOS Init Script

Aline Manera alinefm at linux.vnet.ibm.com
Wed Aug 5 12:57:47 UTC 2015



On 02/07/2015 12:03, Michael Sole wrote:
> I created a very simple CentOS 6 compatible init script. Its a little
> hacky but it does work. I know I am supposed to make a patch but perhaps
> someone can evaluate and decide if you want to include it:

Any contribution is more than welcome! Specially when we can increase 
the number of Linux distributions Kimchi runs well! =)

> #!/bin/sh
> #
> # Name: Kimchi init script for CentOS 6
> # Author: Michael Sole
> # Email: michael.sole(at)soledevelopment.com
> #
> # Description: Very simple init script to start, stop and restart the
> Kimchi control panel
> #
> # Usage: /etc/init.d/kimchid start|stop|restart
>
> ### BEGIN INIT INFO
> # Provides: kimchid
> # Required-Start: $local_fs $syslog
> # Required-Stop: $local_fs $syslog
> # Default-Start:  2345
> # Default-Stop: 90
> # Short-Description: run kimchi daemon
> # Description: Very simple init script to start, stop and restart the
> Kimchi control panel
> ### END INIT INFO

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

This library has a lot of useful functions that we can use here.

Check some of them: loadproc, reloadproc, statusproc, killproc, 
check_script_status, print_status,

> exec="/usr/bin/kimchid"
> prog="kimchid"
>
> lockfile=/var/lock/subsys/$prog
>
> start() {
>      if [ -f "$lockfile" ]
>      then
>          echo "Lock file found, is the daemon already running?"
>          exit 5
>      fi
>      echo -n $"Starting $prog: "

>      nohup $exec  > /dev/null 2>&1 &
>      echo "OK"
>      touch $lockfile

I am not familiar of CentOS but I'd say try to use the loadproc() 
functions would be better to start the process.

>      return 0
> }
>
> stop() {
>      echo -n $"Stopping $prog: "
>      rm -f $lockfile
>      ps aux | grep -ie $prog | awk '{print $2}' | xargs kill -9 > /dev/null
> 2>&1
>      return 0
> }

Maybe use killproc() function and avoiding using 'kill -9' ? =)

> restart() {
>      stop
>      start
> }
>
> case "$1" in
>      start)
>          $1
>          ;;
>      stop)
>          $1
>          ;;
>      restart)
>          $1
>          ;;
>      *)
>          echo $"Usage: $0 {start|stop|restart}"
>          exit 2
> esac
> exit $?
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list