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_var_run_load() { 21 test -f ${var_run_mtree} && 22 mtree -U -i -q -f ${var_run_mtree} -p /var/run > /dev/null 23} 24 25_var_run_save() { 26 if [ ! -d $(dirname ${var_run_mtree}) ]; then 27 mkdir -p ${var_run_mtree} 28 fi 29 mtree -dcbj -p /var/run > ${var_run_mtree} 30} 31 32_var_run_start() { 33 df -ttmpfs /var/run > /dev/null 2>&1 && 34 _var_run_load 35} 36 37_var_run_stop() { 38 df -ttmpfs /var/run > /dev/null 2>&1 && 39 checkyesno var_run_autosave && 40 _var_run_save 41} 42 43run_rc_command "$1" 44