From 1947d0b35e59aed4bc616609f17499a534d4df91 Mon Sep 17 00:00:00 2001 From: OnGle Date: Tue, 9 Feb 2016 23:59:22 +0000 Subject: [PATCH 1/3] Retabbed init.d script Retabbed init.d script due to mixture of spaces/tabs. --- overlay/etc/init.d/openerp-server | 190 +++++++++++++++--------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/overlay/etc/init.d/openerp-server b/overlay/etc/init.d/openerp-server index 07975be..8b22dcc 100755 --- a/overlay/etc/init.d/openerp-server +++ b/overlay/etc/init.d/openerp-server @@ -9,15 +9,15 @@ # config: /etc/odoo/openerp-server.conf ### BEGIN INIT INFO -# Provides: openerp-server -# Required-Start: $remote_fs $syslog postgresql -# Required-Stop: $remote_fs $syslog postgresql -# Should-Start: $network -# Should-Stop: $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Open Enterprise Resource Management software -# Description: Odoo is a complete ERP and CRM software. +# Provides: openerp-server +# Required-Start: $remote_fs $syslog postgresql +# Required-Stop: $remote_fs $syslog postgresql +# Should-Start: $network +# Should-Stop: $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Open Enterprise Resource Management software +# Description: Odoo is a complete ERP and CRM software. ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin @@ -34,11 +34,11 @@ MAX_WAIT=15 # Log event to DAEMON_LOGFILE function dlog(){ - DLOG_ENTRY=(`date -R`)" - $1" - echo "${DLOG_ENTRY}" - [ -f $DAEMON_LOGFILE ] || return 1 - echo "${DLOG_ENTRY}" >> ${DAEMON_LOGFILE} - return 0 + DLOG_ENTRY=(`date -R`)" - $1" + echo "${DLOG_ENTRY}" + [ -f $DAEMON_LOGFILE ] || return 1 + echo "${DLOG_ENTRY}" >> ${DAEMON_LOGFILE} + return 0 } # Returns 0 if pid/process exists @@ -51,98 +51,98 @@ function checkpid(){ # Returns 0 if any process owned by $USER function checkproc(){ - ps -U $USER -u $USER f | grep -qEv 'PID' || return 0 - return 1 + ps -U $USER -u $USER f | grep -qEv 'PID' || return 0 + return 1 } # Retruns the status of the server function get-status(){ - echo "Getting status of Odoo Server:" - ps -U $USER -u $USER f | grep -Ev 'PID' || echo "Odoo server is not running" + echo "Getting status of Odoo Server:" + ps -U $USER -u $USER f | grep -Ev 'PID' || echo "Odoo server is not running" } # Create lock file function start-lock(){ - [ -f $LOCKFILE ] && return 1 - touch $LOCKFILE || return 1 - dlog "script called - lock file created" - dlog "created ${LOCKFILE}" - return 0 + [ -f $LOCKFILE ] && return 1 + touch $LOCKFILE || return 1 + dlog "script called - lock file created" + dlog "created ${LOCKFILE}" + return 0 } # Remove lock file function remove-lock(){ - [ -f $LOCKFILE ] || return 1 - rm $LOCKFILE || return 1 - dlog "script ending - lock file removed" + [ -f $LOCKFILE ] || return 1 + rm $LOCKFILE || return 1 + dlog "script ending - lock file removed" dlog "removed ${LOCKFILE}" - return 0 + return 0 } # Wait until stopped function stop-wait(){ - dlog "Waiting for process to stop" - XSTOP=1 - XCOUNT=1 - until [ $XSTOP ] - do - sleep 1 - [! checkpid && checkproc ] || XSTOP=0 - [ $MAX_WAIT -ge $XCOUNT ] && XSTOP=0 - XCOUNT=$((XCOUNT+1)) - done - - if [! checkpid && checkproc ]; then - return 0 - else - return 1 - fi + dlog "Waiting for process to stop" + XSTOP=1 + XCOUNT=1 + until [ $XSTOP ] + do + sleep 1 + [! checkpid && checkproc ] || XSTOP=0 + [ $MAX_WAIT -ge $XCOUNT ] && XSTOP=0 + XCOUNT=$((XCOUNT+1)) + done + + if [! checkpid && checkproc ]; then + return 0 + else + return 1 + fi } # Starts the server function server-start(){ - dlog "Starting ${DESC}" - start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ - --chuid ${USER} --background --no-close --make-pidfile \ - --exec ${DAEMON} -- --config=${CONFIG} >> ${DAEMON_LOGFILE} 2>&1 - - sleep 1 - - if [ checkproc ]; then - dlog "${DESC} started!" - return 0 - else - dlog "${DESC} failed to start!" - return 1 - fi + dlog "Starting ${DESC}" + start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ + --chuid ${USER} --background --no-close --make-pidfile \ + --exec ${DAEMON} -- --config=${CONFIG} >> ${DAEMON_LOGFILE} 2>&1 + + sleep 1 + + if [ checkproc ]; then + dlog "${DESC} started!" + return 0 + else + dlog "${DESC} failed to start!" + return 1 + fi } # Stops the server function server-stop(){ - - dlog "Stopping ${DESC}" - start-stop-daemon --stop --quiet --pidfile ${PIDFILE} --remove-pidfile --oknodo + + dlog "Stopping ${DESC}" + start-stop-daemon --stop --quiet --pidfile ${PIDFILE} --remove-pidfile --oknodo - # Wait until process is stopped + # Wait until process is stopped - if [ stop-wait ]; then - dlog "${DESC} stopped" - return 0 - else - dlog "${DESC} timed out while waiting to stop" - return 1 - fi + if [ stop-wait ]; then + dlog "${DESC} stopped" + return 0 + else + dlog "${DESC} timed out while waiting to stop" + return 1 + fi } # Exit script with code function exit-script(){ - remove-lock - dlog "script exit code: $1" - EXITCODE=$1 + remove-lock + dlog "script exit code: $1" + EXITCODE=$1 } set -e @@ -159,30 +159,30 @@ start-lock || exit-script 1 case "${1}" in - start) - server-start || exit-script 1 - ;; - - stop) - server-stop || exit-script 1 - ;; - - restart|force-reload) - dlog "Restarting ${DESC}" - server-stop || exit-script 1 - sleep 1 - server-start || exit-script 1 - ;; - - status) - get-status - ;; - - *) - N=/etc/init.d/${NAME} - echo "Usage: ${NAME} {start|stop|status|restart|force-reload}" >&2 - exit-script 1 - ;; + start) + server-start || exit-script 1 + ;; + + stop) + server-stop || exit-script 1 + ;; + + restart|force-reload) + dlog "Restarting ${DESC}" + server-stop || exit-script 1 + sleep 1 + server-start || exit-script 1 + ;; + + status) + get-status + ;; + + *) + N=/etc/init.d/${NAME} + echo "Usage: ${NAME} {start|stop|status|restart|force-reload}" >&2 + exit-script 1 + ;; esac exit-script 0 From 91ed23f582f93d1c2050e8752eaee1431947556c Mon Sep 17 00:00:00 2001 From: OnGle Date: Wed, 10 Feb 2016 02:11:45 +0000 Subject: [PATCH 2/3] Fixed bugs #521, #522 odoo init.d script was not checking for already running odoo when starting service meaning that process would become detached from the pid file and would not be recognised as odoo processes. This caused both bugs #521 and #522. Fix was to check for running odoo process. --- overlay/etc/init.d/openerp-server | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/overlay/etc/init.d/openerp-server b/overlay/etc/init.d/openerp-server index 8b22dcc..b68c00c 100755 --- a/overlay/etc/init.d/openerp-server +++ b/overlay/etc/init.d/openerp-server @@ -45,14 +45,8 @@ function dlog(){ function checkpid(){ [ -f $PIDFILE ] || return 1 pid=`cat $PIDFILE` - [ -d /proc/$pid ] && return 0 - return 1 -} - -# Returns 0 if any process owned by $USER -function checkproc(){ - ps -U $USER -u $USER f | grep -qEv 'PID' || return 0 - return 1 + [ -d /proc/$pid ] && return 0 + return 1 } # Retruns the status of the server @@ -87,12 +81,12 @@ function stop-wait(){ until [ $XSTOP ] do sleep 1 - [! checkpid && checkproc ] || XSTOP=0 + [! checkpid ] || XSTOP=0 [ $MAX_WAIT -ge $XCOUNT ] && XSTOP=0 XCOUNT=$((XCOUNT+1)) done - if [! checkpid && checkproc ]; then + if [! checkpid ]; then return 0 else return 1 @@ -102,6 +96,8 @@ function stop-wait(){ # Starts the server function server-start(){ + # checkpid function seemed unreliable for unknown reasons so here we basically replicate it's functionality. + [ -f "$PIDFILE" ] && [ -d "/proc/$(cat $PIDFILE)" ] && echo "service already running" && return 1 dlog "Starting ${DESC}" start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ From 0a8dfac63d4422f0c90437a1b87d49bfa8a2e0f3 Mon Sep 17 00:00:00 2001 From: OnGle Date: Wed, 10 Feb 2016 02:36:48 +0000 Subject: [PATCH 3/3] Updated changelog --- changelog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/changelog b/changelog index e4f196e..64dd6c5 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,15 @@ +turnkey-odoo-14.1 (1) turnkey; urgency=low + + * Odoo + + - Latest upstream version of odoo 8.0 branch via git + - Fixed bugs #521, #522 + + * Note: Please refer to turnkey-core's changelog for changes common to all + appliances. + + -- Stefan Davis Wed, 10 Feb 2016 02:26:00 +1100 + turnkey-odoo-14.0 (1) turnkey; urgency=low * Initial release of appliance: