Help adapting a Linux init script to FreeBSD-12

Odhiambo Washington odhiambo at gmail.com
Sat Jul 25 20:00:38 UTC 2020


Hello  everyone,

I'm wondering if someone would be willing to assist me adapt a Linux init
script to conform with FreeBSD-12 so that I can control Mailman3 that I
have installed.
I was thinking of relying on the one for mailman (2.1.x), but things seem a
little different.
So far this script below can start|stop mailman3 without a problem, but I'd
like a situation where it can do the same across reboots.
Please let me know what you think:

<cut>
root at gw:/opt/mailman/mm # less /usr/local/etc/rc.d/mailman3
### 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=mailman
USER=mailman3
GROUP=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
</cut>

Thanks in advance for your input.



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


More information about the freebsd-questions mailing list