~syleam/openobject-server/trunk-manage-tablespace

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# openerp-server        This shell script takes care of starting and stopping
#                       OpenERP server
#
# chkconfig: 345 95 05
# description: OpenERP server
#
# pidfile: /var/run/openerp-server.pid
# config: /etc/openerp-server.conf

### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: postgresql
# Required-Stop: postgresql
# Should-Start: $network harddrake
# Default-Start: 345
# Short-Description: Launches the OpenERP server.
# Description: This startup script launches the OpenERP server.
### END INIT INFO

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

PIDFILE=/var/run/openerp/openerp-server.pid
LOCKFILE=/var/lock/subsys/openerp-server
LOGFILE=/var/log/openerp/openerp-server.log

OPTS="--pidfile=$PIDFILE --logfile=$LOGFILE"

prog="openerp-server"
desc="OpenERP Server Daemon"

# check if the openerp-server conf file is present, then use it
if [ -f /etc/openerp-server.conf ]; then
    OPTS="$OPTS -c /etc/openerp-server.conf"
fi

# Source function library
if [ -f /etc/init.d/functions ] ; then
    . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
    . /etc/rc.d/init.d/functions
else
 exit 0
fi

# check the existence of the openerp-server script
[ -z "/usr/bin/openerp-server" ] && exit 0

RETVAL=0

start() {
    if [ -d /etc/openerp/start.d ] ; then
        echo -n $"Preparing $desc: "
        run-parts --exit-on-error /etc/openerp/start.d
        RETVAL=$?
        echo
        [ $RETVAL -ne 0 ] && return $RETVAL
    fi
    
    echo -n $"Starting $desc ($prog): "
    daemon --user openerp --check openerp-server \
    "/usr/bin/setsid /usr/bin/openerp-server \
    -c /etc/openerp-server.conf \
    --pidfile=$PIDFILE \
    --logfile=$LOGFILE &"

    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $LOCKFILE
    return $RETVAL
}

stop() {
    echo -n $"Stopping $desc ($prog): "
    kill -TERM `cat $PIDFILE` > /dev/null 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
        rm -f $LOCKFILE

        echo_success
        echo
    else
        echo_failure
        echo
    fi
    if [ -d /etc/openerp/stop.d ] ; then
        echo -n $"Clearing $desc: "
        run-parts /etc/openerp/stop.d
        echo
    fi
    return $RETVAL
}

restart() {
    stop
    start
}    

condrestart() {
    [ -e $LOCKFILE ] && restart || :
}

status() { 
    if [ -f $PIDFILE ] ; then
        checkpid `cat $PIDFILE`
        RETVAL=$?
        if [ $RETVAL -eq 0 ] ; then
            echo  $"$prog is running..."
        else
            echo  $"$prog is stopped"
        fi
    else
        echo  $"$prog is stopped"
    fi
    return $RETVAL
}

case "$1" in
start)
    start
    ;;

stop)
    stop
    ;;

restart|reload)
    restart
    ;;

condrestart)
    condrestart
    ;;

status)
    status
    ;;

probe)
    exit 0
    ;;

*)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
    exit 1
esac