Retrospect Service for FreeBSD

Last updated: August 28th, 2018

Current as of May 23rd, 2019.

This is the Retrospect service/script that I've used with FreeBSD 10, 11, and 12.

Save it as /usr/local/etc/rc.d/retro and make it executable, then run this to enable it in /etc/rc.conf:

sysrc retro_enable=YES

You can change the part with retroip to a specific IP if you want to only use Retrospect over a specific interface.


Once the service is created, Retrospect should start on system boot. You can manage the service manually with these commands:

service retro start
service retro status
service retro stop

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: retro
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# /usr/local/etc/rc.d/retro
#
# Make sure the following is set in /etc/rc.conf to enable this service:
# retro_enable="YES"
#
# Retrospect service for FreeBSD
#
# Nicholas Caito
# [email protected]
#
# August 28th, 2018
# - updated service requirement and tested with FreeBSD 11.2
#  (verify order with "rcorder /etc/rc.d/* /usr/local/etc/rc.d/*")
#
# September 7th, 2017
# - updated retroclient startup command.
# - removed checking /etc/sysctl.conf for compat.linux.osrelease. this
#   may not be needed in FreeBSD 10.3 and newer
# - added checks to see if the service is running before trying to
#   start or stop it
# - simplified script formatting and logging
#
# February 6th, 2015
# - updated for change from Fedora -> CentOS
# - updated service to be compliant with "rclint -v" command
# - re-write of much of the commands to enable better logging, display
#   linux kernel version, and to force loading of "sysctl" (in order to
#   set the correct linux kernel parameter).
#
# October 1st, 2014
# - updated for Retrospect 9.5 Linux client
# - added Server IP option (helps reduce log spam)
# - changed startup commands to better match Linux service
# - updated script with 'PROVIDE' for rcorder(8) so ".sh" isn't required
#
# November 6th, 2012
# - first version of script
#

# load system functions
. /etc/rc.subr

# name of service
name=retro

# make sure to set retro_enable="YES" in /etc/rc.conf to enable this
rcvar=retro_enable

# service description
desc="Retrospect service for FreeBSD."

# load service config
load_rc_config $name

# enable 'status' parameter
extra_commands=status

# specify client directory
retrodir=/usr/local/retrospect/client

# specify service log file
logfile=/var/log/retro.log

# current date & time, %F is the same as %Y-%m-%d, %T is the same as %H:%M:%S
when=$(date +"%FT%T")

# specify a IP address to bind to, or listen on all IPs
# retroip=192.168.0.100
retroip=0.0.0.0

# command to start retrospect
cmd="${retrodir}/retroclient -ip ${retroip} > /dev/null 2>&1 &"

# default service start command
start_cmd="${name}_start"

# default service stop command
stop_cmd="${name}_stop"

# status command
status_cmd="${name}_status"

# start service command
retro_start()
{
   # are you root?
   if [ `whoami` != root ]; then
      echo -e "\n** This requires root. **\n"
      exit 1
   fi

   # check if retrospect is already running
   if [ `pgrep -x "retroclient"` ]; then
      echo "Retrospect is already running."
      exit 0
   fi

   # log
   echo -e "\n${when}: -[Starting Retrospect Service]-" >> ${logfile}

   # what is going on
   echo "Starting Retrospect..."

   # run the startup command!
   echo "${when}: Running: '${cmd}'" >> ${logfile}
   eval ${cmd}

   # pause
   sleep 1

   # done
   exit 0
}

# stop service command
retro_stop()
{
   # are you root?
   if [ `whoami` != root ]; then
      echo -e "\n** This requires root. **\n"
      exit 1
   fi

   # check if retrospect is already running
   if [ ! `pgrep -x "retroclient"` ]; then
      echo "Retrospect isn't running."
      exit 0
   fi

   # what is going on
   echo "Stopping Retrospect..."

   # log
   echo "${when}: -[Stopping Retrospect Service]-" >> ${logfile}

   # run command
   ${retrodir}/retrocpl -stop

   # pause
   sleep 1

   # done
   exit 0
}

# status service command
retro_status()
{
   # check if retrospect is already running
   if [ ! `pgrep -x "retroclient"` ]; then
      echo "Retrospect isn't running."
      exit 0
   fi

   # run command
   ${retrodir}/retrocpl

   # done
   exit 0
}

# run one of the above commands
run_rc_command "$1"

# EoF