rc.d/varsym: Rewrite following rc.d/sysctl
[dragonfly.git] / etc / rc.d / varsym
1 #!/bin/sh
2
3 # PROVIDE: varsym
4 # REQUIRE: mountcritremote
5
6 . /etc/rc.subr
7
8 name=varsym
9 rcvar="varsym_enable"
10 required_files="/etc/varsym.conf"
11 start_cmd="varsym_start"
12 stop_cmd=":"
13
14 varsym_start()
15 {
16         local line
17
18         if [ ! -f "/etc/varsym.conf" ]; then
19                 return
20         fi
21
22         # NOTE: Do not miss the last line when it does not end with a LF.
23         while read -r line || [ -n "${line}" ]; do
24                 case ${line} in
25                 \#*|'')
26                         ;;
27                 *[^=\ ]=[^=\ ]*)
28                         debug "varsym -s ${line}"
29                         eval varsym -s ${line}
30                         ;;
31                 *)
32                         warn "invalid syntax: '${line}'"
33                         ;;
34                 esac
35         done < /etc/varsym.conf
36 }
37
38 load_rc_config $name
39 run_rc_command "$1"