-
Notifications
You must be signed in to change notification settings - Fork 0
/
kiconv.sh.in
executable file
·68 lines (59 loc) · 1.77 KB
/
kiconv.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
#
# PROVIDE: kiconv
# REQUIRE: mountcritremote ldconfig
# BEFORE: DAEMON
# KEYWORD: nojail shutdown
#
# Add the following lines to /etc/rc.conf to enable kernel iconv
# tables preloading:
# kiconv_preload (bool): Set to "YES" to enable preloading.
# Default is "NO".
# kiconv_local_charsets (str): Space separated list of local charsets.
# Usually list of locales used on a system.
# kiconv_foreign_charsets (str): Space separated list of foreign charsets.
# Usually UTF-16BE + some location specific
# charsets
# kiconv_charset_pairs (str): Space separated list of additional charset
# pairs in form of LOCAL:REMOTE
#
# See kiconvtool(8) for details
#
. /etc/rc.subr
name="kiconv"
rcvar="kiconv_preload"
load_rc_config $name
: ${kiconv_preload="NO"}
: ${kiconv_local_charsets=""}
: ${kiconv_foreign_charsets=""}
: ${kiconv_charset_pairs=""}
: ${kiconv_fstypes=""}
: ${kiconv_flags=""}
command="%%PREFIX%%/sbin/kiconvtool"
command_args="${kiconv_flags} -l ${kiconv_local_charsets} -f ${kiconv_foreign_charsets} -p ${kiconv_charset_pairs}"
start_cmd="kiconv_start"
stop_cmd=":"
kiconv_start()
{
echo 'Loading kernel iconv modules.'
if ! kldstat -qm iconv; then # sic! we test for iconv, not libiconv
if kldload libiconv; then
info "libiconv module loaded"
else
warn "libiconv module failed to load"
return 1
fi
fi
for fs in ${kiconv_fstypes}; do
if ! kldstat -qm ${fs}_iconv; then
if kldload ${fs}_iconv; then
info "${fs}_iconv module loaded"
else
warn "${fs}_iconv module failed to load"
fi
fi
done
echo 'Loading kernel iconv tables.'
${command} ${command_args}
}
run_rc_command "$1"