Port upgrade issue

Leander Schäfer info at netocean.de
Mon Jan 19 16:24:42 UTC 2015


Hi,

I have optimized the current rsyncd rc script some time ago. Added 
features are e.g.:

  * run multiple instances - as known eg. by OpenVPN rc-script
  * pid & lock files cleaned up nicely under
    /var/run/rsync/{instance}.{pid,lock}
  * added rc.conf variables for better control
      o NAME_pidfile="/var/run/rsync/NAME.pid" # Where to write process id
      o NAME_lockfile="/var/run/rsync/NAME.lock" # Support for the lqmax
        connectionsrq parameter

This way the FreeBSD user can change pid and lock file without screwing 
up rc-script expectations.

The port maintainer offered to apply the changes if I would provide them 
to him as diff patch.



Emanuel Haupt said:

    [...] You're the first one to ask for such a feature ever since I
    maintain this port. But tell you what, If you can fabricate a clean,
    well tested (poudriere logs) patch I will commit it. [...]


Well I did so (a couple of times) via email but unfortunately he never 
replied or made any other move. Eventually I decided to open up a commit 
request as described in the 
Handbook_https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195232_

Unfortunately nothing has changed since ever then. I don't know if 
something happened to the port maintainer or if he simply doesn't have 
internet access anymore?! Now my question is what can I do / Who can I 
ask to apply this patch?

Thank you
-------------- next part --------------
--- ./rsyncd-current	2015-01-19 14:04:33.000000000 +0100
+++ /usr/local/etc/rc.d/rsyncd	2014-10-30 13:44:51.000000000 +0100
@@ -8,39 +8,83 @@
 # BEFORE:  securelevel
 # KEYWORD: shutdown
 
-# Add the following lines to /etc/rc.conf to enable `rsyncd':
+# -----------------------------------------------------------------------------
 #
-# rsyncd_enable="YES"
-# rsyncd_flags="<set as needed>"
+# This script supports running multiple instances of rsyncd.
+# To run additional instances link this script to something like
+# % ln -s rsyncd rsyncd_foo
+# and define additional rsyncd_foo_* variables in one of
+# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/openvpn_foo
 #
-# See rsync(1) for rsyncd_flags
+# Below NAME should be substituted with the name of this script. By default
+# it is rsyncd, so read as rsyncd_enable. If you linked the script to
+# rsyncd_foo, then read as rsyncd_foo_enable etc.
 #
+# The following variables are supported (defaults are shown).
+# You can place them in any of
+# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/NAME
+#
+# NAME_enable="NO"      # set to YES to enable rsyncd
+#
+# # optional:
+# NAME_configfile="/usr/local/etc/rsync/NAME.conf"  # Where to look for config file
+# NAME_pidfile="/var/run/rsync/NAME.pid"            # Where to write process id
+# NAME_lockfile="/var/run/rsync/NAME.lock"          # Support for the lqmax connectionsrq parameter
+# NAME_flags="<set as needed>"                      # See rsync(1) for NAME_flags
+#
+# -----------------------------------------------------------------------------
 
 . /etc/rc.subr
 
-name="rsyncd"
-rcvar=rsyncd_enable
+case "${0}" in
+/etc/rc*)
+    # during boot (shutdown) ${0} is /etc/rc (/etc/rc.shutdown),
+    # so get the name of the script from $_file
+    name="${_file}"
+    ;;
+*)
+    name="${0}"
+    ;;
+esac
+
+name="${name##*/}"
+rcvar=${name}_enable
+
 
 command="/usr/local/bin/rsync"
 start_precmd="rsyncd_precmd"
-pidfile="/var/run/$name.pid"
+stop_postcmd="rsyncd_postcmd"
 
 # read configuration and set defaults
-load_rc_config "$name"
-: ${rsyncd_enable="NO"}
-: ${rsyncd_configfile:=/usr/local/etc/rsync/$name.conf}
-
-required_files="${rsyncd_configfile}"
-
-command_args="--daemon --config ${rsyncd_configfile}"
-
-rsyncd_precmd()
-{
-	if [ -f "/usr/local/etc/$name.conf" ] && [ ! -L "/usr/local/etc/$name.conf" ]; then
-		echo "Found /usr/local/etc/$name.conf in old location. Migrating to /usr/local/etc/rsync/$name.conf."
-		mv /usr/local/etc/$name.conf /usr/local/etc/rsync/$name.conf
-		ln -s /usr/local/etc/rsync/$name.conf /usr/local/etc/$name.conf
-	fi
+load_rc_config "${name}"
+eval ": \${${name}_enable:=\"NO\"}"
+eval ": \${${name}_configfile:=\"/usr/local/etc/rsync/${name}.conf\"}"
+eval ": \${${name}_pidfile:=\"/var/run/rsync/${name}.pid\"}"
+eval ": \${${name}_lockfile:=\"/var/run/rsync/${name}.lock\"}"
+
+configfile="$(eval echo \${${name}_configfile} )"
+pidfile="$(eval echo \${${name}_pidfile})"
+lockfile="$(eval echo \${${name}_lockfile})"
+
+required_files="${configfile}"
+
+command_args="--daemon --config ${configfile} --dparam=pidfile=${pidfile} --dparam=lockfile=${lockfile}"
+
+rsyncd_precmd () {
+    mkdir -p -m 0755 "$(dirname ${pidfile})"
+    mkdir -p -m 0755 "$(dirname ${lockfile})"
+    if [ -f "/usr/local/etc/${name}.conf" ] && [ ! -L "/usr/local/etc/${name}.conf" ]; then
+        echo "Found /usr/local/etc/${name}.conf in old location. Migrating to ${configfile}."
+        mv /usr/local/etc/${name}.conf ${configfile}
+        ln -s ${configfile} /usr/local/etc/${name}.conf
+    fi
 }
 
-run_rc_command "$1"
+rsyncd_postcmd() {
+    rmdir "$(dirname ${pidfile})"  > /dev/null 2>&1
+    rmdir "$(dirname ${lockfile})" > /dev/null 2>&1
+}
+
+run_rc_command "${1}"
+
+


More information about the freebsd-ports mailing list