Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107384663
D36386.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D36386.diff
View Options
diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist
--- a/etc/mtree/BSD.var.dist
+++ b/etc/mtree/BSD.var.dist
@@ -46,6 +46,8 @@
..
ipf mode=0700 tags=package=ipf
..
+ mtree
+ ..
ntp uname=ntpd gname=ntpd
..
pkg
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -61,6 +61,12 @@
mfs_type="auto" # "md", "tmpfs", "auto" to prefer tmpfs with md as fallback
populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never
cleanvar_enable="YES" # Clean the /var directory
+var_run_enable="NO" # Save/restore /var/run structure at shutdown/reboot
+var_run_autosave="NO" # Only restore /var/run structure at shutdown/reboot
+ # The user is expected to issue service var_run save to
+ # manually save the /var/run mtree
+var_run_mtree="/var/db/mtree/BSD.var-run.mtree"
+ # Where to save /var/run mtree
local_startup="${_localbase}/etc/rc.d" # startup script dirs.
script_name_sep=" " # Change if your startup scripts' names contain spaces
rc_conf_files="/etc/rc.conf /etc/rc.conf.local"
diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile
--- a/libexec/rc/rc.d/Makefile
+++ b/libexec/rc/rc.d/Makefile
@@ -111,6 +111,7 @@
ugidfw \
${_utx} \
var \
+ var_run \
watchdogd
.if ${MK_NIS} != "no"
diff --git a/libexec/rc/rc.d/var_run b/libexec/rc/rc.d/var_run
new file mode 100755
--- /dev/null
+++ b/libexec/rc/rc.d/var_run
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# PROVIDE: var_run
+# REQUIRE: mountcritlocal
+# BEFORE: cleanvar
+
+. /etc/rc.subr
+
+name=var_run
+rcvar=var_run_enable
+extra_commands="load save"
+start_cmd="_var_run_start"
+load_cmd="_var_run_load"
+save_cmd="_var_run_save"
+stop_cmd="_var_run_stop"
+
+load_rc_config $name
+
+# Set defaults
+: ${var_run_enable:="NO"}
+: ${var_run_mtree:="/var/db/mtree/BSD.var-run.mtree"}
+: ${var_run_autosave:="YES"}
+
+_var_run_load() {
+ test -f ${var_run_mtree} &&
+ mtree -U -i -q -f ${var_run_mtree} -p /var/run > /dev/null
+}
+
+_var_run_save() {
+ if [ ! -d $(dirname ${var_run_mtree}) ]; then
+ mkdir -p ${var_run_mtree}
+ fi
+ mtree -dcbj -p /var/run > ${var_run_mtree}
+}
+
+_var_run_start() {
+ df -ttmpfs /var/run > /dev/null 2>&1 &&
+ _var_run_load
+}
+
+_var_run_stop() {
+ df -ttmpfs /var/run > /dev/null 2>&1 &&
+ checkyesno var_run_autosave &&
+ _var_run_save
+}
+
+run_rc_command "$1"
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -463,6 +463,34 @@
Clean the
.Pa /var
directory.
+.It Va var_run_enable
+.Pq Vt bool
+Set to "YES" to enable saving of the
+.Pa /var/run
+directory strcucture into an mtree file at shutdown and the reload of the
+.Pa /var/run
+directory structure at boot.
+.It Va var_run_autosave
+.Pq Vt bool
+In some cases it may be undesirable to save
+.Pa /var/run
+at shutdown.
+When set to "NO"
+.Pa /var/run
+is loaded at reboot but not saved at shutdown. Typically in this scenario
+a
+.Pa service
+.Pa var_run
+.Pa save
+would be performed to save a copy of the
+.Pa /var/run
+directory structure once, to be reload during all subsequent reboots.
+.It Va var_run_mtree
+.Pq Vt str
+Where to save the
+.Pa /var/run
+mtree. The default location is
+.Pa /var/db/mtree/BSD.var-run.mtree .
.It Va local_startup
.Pq Vt str
List of directories to search for startup script files.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 14, 9:33 AM (16 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15793044
Default Alt Text
D36386.diff (3 KB)
Attached To
Mode
D36386: libexec/rc: Add var_run rc script
Attached
Detach File
Event Timeline
Log In to Comment