Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- #
- # TinyERP
- NAME=tinyerp
- DESC="TinyERP Server"
- DAEMON=/usr/bin/tinyerp-server
- DAEMON_ARGS="--db_host=localhost --db_port=5432 --database=terp --db_user=terp --db_password=terp"
- PIDFILE=/var/run/$NAME.pid
- WEB_DAEMON=/usr/bin/start-tinyerp
- WEB_PIDFILE=/var/run/etiny-server.pid
- LOG_PATH=/var/log/tinyERP
- LOG_SERVER=tiny_serv.log
- PID=$(cat $PIDFILE &)
- ###########################################################
- if [ $(whoami) != 'tinyerp' ] ; then
- echo 'Permission denied: This script must be run as tinyerp !'
- exit 1
- fi
- do_start() {
- # Check if server is running
- if ps --pid $PID > /dev/null ; then
- echo "$DESC is already running !\n"
- exit 1
- fi
- start-stop-daemon --start --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS >> $LOG_PATH/$LOG_SERVER &
- start-stop-daemon --start --make-pidfile --pidfile $WEB_PIDFILE --exec $WEB_DAEMON &
- }
- do_stop() {
- # Check if server is running
- if ! ps --pid $PID > /dev/null ; then
- echo "$DESC is not running !\n"
- exit 1
- fi
- start-stop-daemon --stop --pidfile $PIDFILE
- start-stop-daemon --stop --signal HUP --pidfile $WEB_PIDFILE
- }
- case "$1" in
- start)
- echo "Starting $DESC...\n"
- do_start
- ;;
- stop)
- echo "Stopping $DESC...\n"
- do_stop
- ;;
- restart)
- echo "Restarting $DESC:"
- echo " Stopping $DESC..."
- do_stop
- sleep 0.5
- echo " Starting $DESC...\n"
- do_start
- ;;
- # Default behaviour
- *)
- echo "Usage: /etc/init.d/tinyerp {start|stop|restart}\n" >&2
- echo
- exit 2
- ;;
- esac
- exit 0
Add Comment
Please, Sign In to add comment