To know the steps on how to install this code click here
#!/bin/sh ######################################################## ########## +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+########## ########## Technaureus Info Solutions Pvt Ltd ########## ########## +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+########## ######################################################## ### BEGIN INIT INFO # Provides: odoo-server # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Name: Odoo start/stop script for Ubuntu # Author: Technaureus Info Solutions Pvt Ltd. # Website: https://technaureus.com # Description: Using this script, we can start/stop/restart # or check status of odoo server. # # Copyright(c)-2016-Present Technaureus Info Solutions Pvt. Ltd. # All Rights Reserved. ### END INIT INFO PATH=/bin:/sbin:/usr/bin NAME=odoo18-server DESC=ODOO18-SERVER # Specify the daemon path for Odoo server. # (Default for ODOO >=10: /opt/odoo/odoo-bin) # (Default for ODOO <=9: /opt/odoo/openerp-server) DAEMON=/opt/odoo18/odoo/odoo-bin CONFIGFILE="/etc/odoo18-server.conf" # Specify the Odoo Configuration file path.
USER=odoo18 # Specify the user name (Default: odoo).
PIDFILE=/var/run/$NAME.pid # pidfile
# Additional options that are passed to the Daemon. DAEMON_ARGS="-c $CONFIGFILE"
display() { RED=$(tput setaf 1) GREEN=$(tput setaf 2) NORMAL=$(tput sgr0) col=$(tput cols) case "$#" in 1) if [ $1 -eq 0 ] ; then printf '%s%*s%s' "$GREEN" $col "[ OK ] " "$NORMAL" else printf '%s%*s%s' "$RED" $col "[FAIL] " "$NORMAL" fi ;; 2) if [ $1 -eq 0 ] ; then echo "$GREEN* $2$NORMAL" else echo "$RED* $2$NORMAL" fi ;; *) echo "Invalid arguments" exit 1 ;; esac }
if ! [ -x $DAEMON ] ; then echo "Error in ODOO Daemon file: $DAEMON" echo "Possible error(s):" display 1 "Daemon File doesn't exists." display 1 "Daemon File is not set to executable." exit 0; fi if ! [ -r $CONFIGFILE ] ; then echo "Error in ODOO Config file: $CONFIGFILE" echo "Possible error(s):" display 1 "Config File doesn't exists." display 1 "Config File is not set to readable." exit 0; fi if ! [ -w $PIDFILE ] ; then touch $PIDFILE || echo "Permission issue: $PIDFILE" && exit 1 chown $USER: $PIDFILE fi
# Function that starts the daemon/service do_start() { echo $1 check_status procs=$? if [ $procs -eq 0 ] ; then start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ --chuid ${USER} --background --make-pidfile \ --exec ${DAEMON} -- ${DAEMON_ARGS} return $? else detailed_info "${DESC} is already Running !!!" $procs exit 1 fi }
# Function that stops the daemon/service do_stop() { echo $1 check_status if [ $? -ne 0 ] ; then start-stop-daemon --stop --quiet --pidfile ${PIDFILE} return $? else display 0 "${DESC} is already Stopped. You may try: $0 force-restart" exit 1 fi }
0