rc.d: Add a vfs_accounting script
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 15 Jan 2012 21:33:08 +0000 (22:33 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 15 Jan 2012 21:38:08 +0000 (22:38 +0100)
* Its only function for now is to synchronize counters with the real
  disk usage of a list of mount points

* Small rc.conf example:
  vfs_accounting_enable="YES"
  vfs_accounting_sync="/home /mnt/data"

etc/rc.d/vfs_accounting [new file with mode: 0644]
share/man/man5/rc.conf.5

diff --git a/etc/rc.d/vfs_accounting b/etc/rc.d/vfs_accounting
new file mode 100644 (file)
index 0000000..58436aa
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# PROVIDE: vfs_accounting
+# REQUIRE: mountcritlocal
+# BEFORE:  LOGIN
+
+. /etc/rc.subr
+
+name="vfs_accounting"
+rcvar=`set_rcvar`
+start_cmd="vas_start"
+
+vas_start()
+{
+       if checkyesno vfs_accounting_enable; then
+               # For each dir in $vfs_accounting_sync, run vquota sync
+               #
+               case ${vfs_accounting_sync} in
+               [Nn][Oo] | '')
+                       ;;
+               *)
+                       echo -n 'Synchronizing VFS counters: '
+                       for dir in ${vfs_accounting_sync}; do
+                               echo -n "${dir} "
+                               if [ -d "${dir}" ]; then
+                                       /sbin/vquota sync ${dir}
+                               fi
+                       done
+                       echo '.'
+                       ;;
+               esac
+       fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
index 9c76a23..ee40869 100644 (file)
@@ -2661,6 +2661,16 @@ has not completed within the specified time (in seconds).
 If set to
 .Dq Li YES ,
 the udevd daemon will be started on boot.
+.It Va vfs_accounting_enable
+.Pq Vt bool
+If set to
+.Dq Li YES ,
+vfs accounting rc.d scripts will be run on boot.
+.It Va vfs_accounting_sync
+.Pq Vt str
+List of mount points whose counters are to be synchronized with on-disk
+usage during system startup. See also
+.Xr vquota 8 .
 .It Va vknetd_enable
 .Pq Vt bool
 If set to