xref: /freebsd/libexec/rc/rc.d/var_run (revision 56b17de1e8360fe131d425de20b5e75ff3ea897c)
1#!/bin/sh
2
3# PROVIDE: var_run
4# REQUIRE: mountcritlocal
5# BEFORE: cleanvar
6# KEYWORD: shutdown
7
8. /etc/rc.subr
9
10name=var_run
11rcvar=var_run_enable
12extra_commands="load save"
13start_cmd="_var_run_start"
14load_cmd="_var_run_load"
15save_cmd="_var_run_save"
16stop_cmd="_var_run_stop"
17
18load_rc_config $name
19
20# doesn't make sense to run in a svcj: config setting
21var_run_svcj="NO"
22
23_var_run_load() {
24	test -f ${var_run_mtree} &&
25		mtree -U -i -q -f ${var_run_mtree} -p /var/run > /dev/null
26}
27
28_var_run_save() {
29	if [ ! -d $(dirname ${var_run_mtree}) ]; then
30		mkdir -p ${var_run_mtree}
31	fi
32	mtree -dcbj -p /var/run > ${var_run_mtree}
33}
34
35_var_run_start() {
36	df -ttmpfs /var/run > /dev/null 2>&1 &&
37		_var_run_load
38}
39
40_var_run_stop() {
41	df -ttmpfs /var/run > /dev/null 2>&1 &&
42		checkyesno var_run_autosave &&
43			_var_run_save
44}
45
46run_rc_command "$1"
47