为openerp-server建立service
-
在/etc/init.d下建立文件openerp-server
如果安装了openerp-web,可将openerp-web复制过来修改
内容大致如下:
#!/bin/shBEGIN INIT INFO
Provides: openerp-server
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 Server - the Server of the OpenERP
Description: OpenERP is a complete ERP and CRM software.
END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/start-openerp-server
NAME=openerp-server
DESC=openerp-serverSpecify the user name (Default: terp).
USER="openerp"
logfile
LOGFILE="/var/log/openerp-server.log"
pidfile
PIDFILE=/var/run/$NAME.pid
Additional options that are passed to the Daemon.
DAEMON_OPTS="--logfile $LOGFILE"
[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0checkpid() {
[ -f $PIDFILE ] || return 1
pid=cat $PIDFILE
[ -d /proc/$pid ] && return 0
return 1
}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 $?
}
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
;;
esacexit 0
vim: sts=4 st=4 et