Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Aug 2020 10:10:46 +0300
From:      Odhiambo Washington <odhiambo@gmail.com>
To:        questions <questions@freebsd.org>
Subject:   creating a startup script for a foreign application
Message-ID:  <CAAdA2WPwwzaP4F2ZTXTAvFAAgXDYk0OiM6fsERbGjMK=s7v0KA@mail.gmail.com>

Next in thread | Raw E-Mail | Index | Archive | Help
Hi good people,

I am looking for assistance in creating a startup script for rc.d/ to
automatically start/stop a service upon reboot.
I have installed Mailman3.x in a python virtual environment and I have
adopted a script from Linux to control it.
I am able to use the script to manually start|stop the application.
However, it does not work when I reboot the system.

Hoping someone can help me tinker with it so that it works with system
reboots.

Below is the content of the script currently.

<BEGIN>
#!/usr/local/bin/bash

### BEGIN INIT INFO
# Provides:            GNU Mailman
# Required-Start:      $local_fs $network
# Required-Stop:       $local_fs $network
# Default-Start:       2 3 4 5
# Default-Stop:        0 1 6
# Short-Description:   Mailman Service
# Description:         service control for Mailman
### END INIT INFO

PATH=/opt/mailman/mm/bin:/opt/mailman/mm/venv/bin:/usr/sbin:/usr/bin:/bin:/sbin:
DESC="GNU Mailman service"
DAEMON=/opt/mailman/mm/bin/mailman
NAME=mailman3
USER=mailman3

# Needed by click
export LANG=en_US.UTF-8

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
#. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
#. /lib/lsb/init-functions

case "$1" in
  start)
        [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"
        # use --force to remove a stale lock.
        /usr/local/bin/sudo -u $USER $DAEMON start --force
        ;;
  stop)
        [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"
        /usr/local/bin/sudo -u $USER $DAEMON stop
        ;;
  status)
        /usr/local/bin/sudo -u $USER $DAEMON status
        ;;
  reopen)
        /usr/local/bin/sudo -u $USER $DAEMON reopen
        ;;
  restart)
        log_daemon_msg "Restarting $DESC" "$NAME"
        /usr/local/bin/sudo -u $USER $DAEMON restart
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|status|reopen|restart}" >&2
        exit 3
        ;;
esac

<END>

Thank you.


-- 
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", grep ^[^#] :-)



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?CAAdA2WPwwzaP4F2ZTXTAvFAAgXDYk0OiM6fsERbGjMK=s7v0KA>