Outils personnels

Contenu de openerp-web : Différence entre versions

De wikiGite

(Page créée avec « #!/bin/sh ### BEGIN INIT INFO # Provides: openerp-web # Required-Start: $syslog # Required-Stop: $syslog # Should-Start: $network # ... »)
 
 
(2 révisions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
 +
= Fichier /etc/init.d/openerp-web =
 +
 
  #!/bin/sh
 
  #!/bin/sh
 
   
 
   
Ligne 34 : Ligne 36 :
 
   
 
   
 
  checkpid() {
 
  checkpid() {
[ -f $PIDFILE ] || return 1
+
    [ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
+
    pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
+
    [ -d /proc/$pid ] && return 0
return 1
+
    return 1
 
  }
 
  }
 
   
 
   
  if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ] ; then
+
  if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ]
 +
then
 +
    do_start() {
 +
      start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER  --background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
 +
      RETVAL=$?
 +
      sleep 5        # wait for few seconds
 +
      return $RETVAL
 +
    }
 
   
 
   
do_start() {
+
    do_stop() {
start-stop-daemon --start --quiet --pidfile $PIDFILE \
+
      start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
--chuid $USER  --background --make-pidfile \
+
      RETVAL=$?
--exec $DAEMON -- $DAEMON_OPTS
+
      sleep 2        # wait for few seconds
+
      rm -f $PIDFILE  # remove pidfile
RETVAL=$?
+
      return $RETVAL
sleep 5        # wait for few seconds
+
    }
 
return $RETVAL
 
}
 
 
do_stop() {
 
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
 
 
RETVAL=$?
 
sleep 2        # wait for few seconds
 
rm -f $PIDFILE  # remove pidfile
 
 
return $RETVAL
 
}
 
 
do_restart() {
 
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
 
 
sleep 2        # wait for few seconds
 
rm -f $PIDFILE  # remove pidfile
 
 
start-stop-daemon --start --quiet --pidfile $PIDFILE \
 
--chuid $USER --background --make-pidfile \
 
--exec $DAEMON -- $DAEMON_OPTS
 
 
RETVAL=$?
 
sleep 5        # wait for few seconds
 
 
return $RETVAL
 
}
 
 
   
 
   
 +
    do_restart() {
 +
      start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
 +
      sleep 2        # wait for few seconds
 +
      rm -f $PIDFILE  # remove pidfile
 +
      start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
 +
      RETVAL=$?
 +
      sleep 5        # wait for few seconds
 +
      return $RETVAL
 +
    }
 
  else
 
  else
 +
    do_start() {
 +
      $DAEMON $DAEMON_OPTS > /dev/null 2>&1 &
 +
      RETVAL=$?
 +
      sleep 5        # wait for few seconds
 +
      echo $! > $PIDFILE  # create pidfile
 +
      return $RETVAL
 +
    }
 
   
 
   
do_start() {
+
    do_stop() {
$DAEMON $DAEMON_OPTS > /dev/null 2>&1 &
+
      pid=`cat $PIDFILE`
+
      kill -15 $pid
RETVAL=$?
+
      RETVAL=$?
sleep 5        # wait for few seconds
+
      sleep 2        # wait for few seconds
+
      rm -f $PIDFILE  # remove pidfile
echo $! > $PIDFILE  # create pidfile
+
      return $RETVAL
+
    }
return $RETVAL
 
}
 
 
do_stop() {
 
 
pid=`cat $PIDFILE`
 
kill -15 $pid
 
 
RETVAL=$?
 
sleep 2        # wait for few seconds
 
rm -f $PIDFILE  # remove pidfile
 
 
return $RETVAL
 
}
 
 
do_restart() {
 
 
if [ -f $PIDFILE ]; then
 
do_stop
 
fi
 
 
do_start
 
 
return $?
 
}
 
 
   
 
   
 +
    do_restart() {
 +
      if [ -f $PIDFILE ]; then
 +
          do_stop
 +
      fi
 +
      do_start
 +
      return $?
 +
    }
 
  fi
 
  fi
 
   
 
   
 
  start_daemon() {
 
  start_daemon() {
+
    if [ -f $PIDFILE ]; then
if [ -f $PIDFILE ]; then
+
      echo "pidfile already exists: $PIDFILE"
echo "pidfile already exists: $PIDFILE"
+
      exit 1
exit 1
+
    fi
fi
+
    echo -n "Starting $DESC: "
+
    do_start
echo -n "Starting $DESC: "
+
    checkpid
+
    if [ $? -eq 1 ]; then
do_start
+
      rm -f $PIDFILE
+
      echo "failed."
checkpid
+
      exit 1
+
    fi
if [ $? -eq 1 ]; then
+
    echo "done."
rm -f $PIDFILE
 
echo "failed."
 
exit 1
 
fi
 
 
echo "done."
 
 
  }
 
  }
 
   
 
   
 
  stop_daemon() {
 
  stop_daemon() {
+
    checkpid
checkpid
+
    if [ $? -eq 1 ]; then
+
      exit 0
if [ $? -eq 1 ]; then
+
    fi
exit 0
+
    echo -n "Stopping $DESC: "
fi
+
    do_stop
+
    if [ $? -eq 1 ]; then
echo -n "Stopping $DESC: "
+
      echo "failed."
+
      exit 1
do_stop
+
    fi
+
    echo "done."
if [ $? -eq 1 ]; then
 
echo "failed."
 
exit 1
 
fi
 
 
echo "done."
 
 
  }
 
  }
 
   
 
   
 
  restart_daemon() {
 
  restart_daemon() {
+
    echo -n "Reloading $DESC: "
echo -n "Reloading $DESC: "
+
    do_restart
+
    checkpid
do_restart
+
    if [ $? -eq 1 ]; then
+
      rm -f $PIDFILE
checkpid
+
      echo "failed."
+
      exit 1
if [ $? -eq 1 ]; then
+
    fi
rm -f $PIDFILE
+
    echo "done."
echo "failed."
 
exit 1
 
fi
 
 
echo "done."
 
 
  }
 
  }
 
   
 
   
 
  status_daemon() {
 
  status_daemon() {
+
    echo -n "Checking $DESC: "
echo -n "Checking $DESC: "
+
    checkpid
+
    if [ $? -eq 1 ]; then
checkpid
+
      echo "stopped."
+
    else
if [ $? -eq 1 ]; then
+
      echo "running."
echo "stopped."
+
    fi
else
 
echo "running."
 
fi
 
 
  }
 
  }
 
   
 
   
Ligne 195 : Ligne 153 :
 
  status) status_daemon ;;
 
  status) status_daemon ;;
 
  *)
 
  *)
N=/etc/init.d/$NAME
+
    N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
+
    echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
+
    exit 1
 
  ;;
 
  ;;
 
  esac
 
  esac
 
   
 
   
 
  exit 0
 
  exit 0

Version actuelle datée du 30 août 2012 à 07:48

Fichier /etc/init.d/openerp-web

#!/bin/sh

### BEGIN INIT INFO
# Provides:             openerp-web
# Required-Start:       $syslog
# Required-Stop:        $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    OpenERP Web - the Web Client of the OpenERP
# Description:          OpenERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/local/bin/openerp-web
NAME=openerp-web
DESC=openerp-web

# Specify the user name (Default: openerp).
USER="openerp"

# Specify an alternate config file (Default: /etc/openerp-web.cfg).
CONFIGFILE="/etc/openerp-web.cfg"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
   [ -f $PIDFILE ] || return 1
   pid=`cat $PIDFILE`
   [ -d /proc/$pid ] && return 0
   return 1
}

if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ]
then
   do_start() {
      start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER  --background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
      RETVAL=$?
      sleep 5         # wait for few seconds
      return $RETVAL
   }

   do_stop() {
      start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
      RETVAL=$?
      sleep 2         # wait for few seconds
      rm -f $PIDFILE  # remove pidfile
      return $RETVAL
   }

   do_restart() {
      start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
      sleep 2         # wait for few seconds
      rm -f $PIDFILE  # remove pidfile
      start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
      RETVAL=$?
      sleep 5         # wait for few seconds
      return $RETVAL
   }
else
   do_start() {
      $DAEMON $DAEMON_OPTS > /dev/null 2>&1 &
      RETVAL=$?
      sleep 5         # wait for few seconds
      echo $! > $PIDFILE  # create pidfile
      return $RETVAL
   }

   do_stop() {
      pid=`cat $PIDFILE`
      kill -15 $pid
      RETVAL=$?
      sleep 2         # wait for few seconds
      rm -f $PIDFILE  # remove pidfile
      return $RETVAL
   }

   do_restart() {
      if [ -f $PIDFILE ]; then
         do_stop
      fi
      do_start
      return $?
   }
fi

start_daemon() {
   if [ -f $PIDFILE ]; then
      echo "pidfile already exists: $PIDFILE"
      exit 1
   fi
   echo -n "Starting $DESC: "
   do_start
   checkpid
   if [ $? -eq 1 ]; then
      rm -f $PIDFILE
      echo "failed."
      exit 1
   fi
   echo "done."
}

stop_daemon() {
   checkpid
   if [ $? -eq 1 ]; then
      exit 0
   fi
   echo -n "Stopping $DESC: "
   do_stop
   if [ $? -eq 1 ]; then
      echo "failed."
      exit 1
   fi
   echo "done."
}

restart_daemon() {
   echo -n "Reloading $DESC: "
   do_restart
   checkpid
   if [ $? -eq 1 ]; then
      rm -f $PIDFILE
      echo "failed."
      exit 1
   fi
   echo "done."
}

status_daemon() {
   echo -n "Checking $DESC: "
   checkpid
   if [ $? -eq 1 ]; then
      echo "stopped."
   else
      echo "running."
   fi
}

case "$1" in
start) start_daemon ;;
stop) stop_daemon ;;
restart|force-reload) restart_daemon ;;
status) status_daemon ;;
*)
   N=/etc/init.d/$NAME
   echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
   exit 1
;;
esac

exit 0