Update Daemon Service Script

pull/428/head
afrizagilleon 1 year ago
parent 0d9e396226
commit 342df17439

@ -230,76 +230,29 @@ sudo chmod 755 $OE_HOME_EXT/start.sh
#-------------------------------------------------- #--------------------------------------------------
echo -e "* Create init file" echo -e "* Create init file"
cat <<EOF > ~/$OE_CONFIG cat <<EOF > ~/$OE_USER.service
#!/bin/sh [Unit]
### BEGIN INIT INFO Description=$OE_USER
# Provides: $OE_CONFIG Requires=postgresql.service
# Required-Start: \$remote_fs \$syslog After=network.target postgresql.service
# Required-Stop: \$remote_fs \$syslog
# Should-Start: \$network [Service]
# Should-Stop: \$network Type=simple
# Default-Start: 2 3 4 5 SyslogIdentifier=$OE_USER
# Default-Stop: 0 1 6 PermissionsStartOnly=true
# Short-Description: Enterprise Business Applications User=$OE_USER
# Description: ODOO Business Applications Group=$OE_USER
### END INIT INFO ExecStart=$OE_HOME/$OE_USER-venv/bin/python3 $OE_HOME/$OE_CONFIG/odoo-bin -c /etc/$OE_CONFIG.conf
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin StandardOutput=journal+console
DAEMON=$OE_HOME_EXT/odoo-bin Restart=always
NAME=$OE_CONFIG RestartSec=5
DESC=$OE_CONFIG
# Specify the user name (Default: odoo).
USER=$OE_USER [Install]
# Specify an alternate config file (Default: /etc/openerp-server.conf). WantedBy=multi-user.target
CONFIGFILE="/etc/${OE_CONFIG}.conf"
# pidfile
PIDFILE=/var/run/\${NAME}.pid
# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c \$CONFIGFILE"
[ -x \$DAEMON ] || exit 0
[ -f \$CONFIGFILE ] || exit 0
checkpid() {
[ -f \$PIDFILE ] || return 1
pid=\`cat \$PIDFILE\`
[ -d /proc/\$pid ] && return 0
return 1
}
case "\${1}" in
start)
echo -n "Starting \${DESC}: "
start-stop-daemon --start --quiet --pidfile \$PIDFILE \
--chuid \$USER --background --make-pidfile \
--exec \$DAEMON -- \$DAEMON_OPTS
echo "\${NAME}."
;;
stop)
echo -n "Stopping \${DESC}: "
start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
--oknodo
echo "\${NAME}."
;;
restart|force-reload)
echo -n "Restarting \${DESC}: "
start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile \$PIDFILE \
--chuid \$USER --background --make-pidfile \
--exec \$DAEMON -- \$DAEMON_OPTS
echo "\${NAME}."
;;
*)
N=/etc/init.d/\$NAME
echo "Usage: \$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
EOF EOF
echo -e "* Security Init File" sudo mv ~/$OE_USER.service /etc/systemd/system/$OE_USER.service
sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG
sudo chmod 755 /etc/init.d/$OE_CONFIG
sudo chown root: /etc/init.d/$OE_CONFIG
echo -e "* Start ODOO on Startup" echo -e "* Start ODOO on Startup"
sudo update-rc.d $OE_CONFIG defaults sudo update-rc.d $OE_CONFIG defaults

Loading…
Cancel
Save