#! /bin/sh ### BEGIN INIT INFO # Provides: md_unix_server # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts the MelissaData UnixSocket server # Description: Starts the MelissaData UnixSocket server ### END INIT INFO NAME=md_unix_server SCRIPTNAME=/etc/init.d/$NAME DAEMON=/usr/bin/$NAME PID_FILE=/var/run/$NAME.pid RUNASUSER=vagrant ARGS="" # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # Function that starts the daemon/service do_start() { start-stop-daemon \ --start --background \ --make-pidfile --pidfile $PID_FILE \ --chuid $RUNASUSER \ --exec $DAEMON -- $ARGS || true } # Function that stops the daemon/service do_stop() { start-stop-daemon --stop --pidfile $PID_FILE } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart) do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) log_action_msg "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac exit 0