blob: 1c1f3285e9f94938b13bc6fca74c2842ef97f41c (
plain) (
blame)
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
|
#!/bin/sh
# PROVIDE: odoo
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Configuration settings for odoo in /etc/rc.conf:
#
# odoo_enable: run odoo server (default=NO)
# odoo_database: define odoo database name (default=odoodb)
# odoo_datadir: directory where odoo store data (default=/var/lib/odoo)
# odoo_flags: additional flags for odoo server (default=--without-demo=all)
#
. /etc/rc.subr
name=odoo
rcvar=odoo_enable
load_rc_config ${name}
: ${odoo_enable:=NO}
: ${odoo_database:="odoodb"}
: ${odoo_datadir:="/var/lib/${name}"}
: ${odoo_flags="--without-demo=all"}
odoo_user="odoo"
pidfile=/var/run/odoo.pid
extra_commands="initdb"
su_cmd="/usr/bin/su"
chown_cmd="/usr/sbin/chown"
mkdir_cmd="/bin/mkdir"
start_cmd="odoo_start"
stop_cmd="odoo_stop"
status_cmd="odoo_status"
restart_cmd="odoo_restart"
initdb_cmd="odoo_initdb"
start_precmd="odoo_start_precmd"
command=/usr/local/bin/odoo
command_args="--database=${odoo_database} --data-dir=${odoo_datadir} --logfile=/var/log/${name}.log --config=%%LOCALBASE%%/etc/odoo/odoo.conf ${odoo_flags}"
odoo_start_precmd() {
odoo_datadir_check
touch ${pidfile}
touch /var/log/${name}.log
${chown_cmd} -R ${odoo_user}:${odoo_user} ${pidfile}
${chown_cmd} -R ${odoo_user}:${odoo_user} /var/log/${name}.log
}
odoo_start()
{
daemon -p ${pidfile} -u ${odoo_user} \
${command} ${command_args}
echo "Starting ${name}"
}
odoo_datadir_check()
{
if [ ! -d "${odoo_datadir}" ]; then
${mkdir_cmd} -p ${odoo_datadir}
${chown_cmd} -R ${odoo_user}:${odoo_user} ${odoo_datadir}
echo "${name} data directory created"
fi
}
odoo_initdb()
{
echo " "
echo "#################################################################"
echo "# #"
echo "# Don't use initdb if you are updating from previous version of #"
echo "# Odoo. Cancel if this is your case (Ctrl + C) #"
echo "# #"
echo "#################################################################"
echo " "
sleep 10
odoo_start_precmd
daemon -p ${pidfile} -u ${odoo_user} \
${command} ${command_args} -i all
echo "Initializing database and starting ${name} server"
}
odoo_restart()
{
echo "Performing restart ${name}"
odoo_stop
sleep 5
odoo_start
}
odoo_status()
{
# If running, show pid
if [ -f ${pidfile} ]
then
echo "${name} is running as pid" `cat ${pidfile}`
else
echo "${name} is not running"
fi
}
odoo_stop()
{
if [ -f ${pidfile} ]
then
kill `cat ${pidfile}`
rm ${pidfile}
echo "Stopping ${name}"
fi
}
run_rc_command "$1"
|