blob: c10da241af04874c59277986b3f6dea38a451579 (
plain) (
blame)
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
|
#!/bin/sh
set_sysctl(){
# Set sysctl value(s) and persist them to /etc/sysctl.conf.
# $1..$N = sysctl values (as "name=value" strings)
# The '|' character is unsupported within the sysctl value.
while [ $# -gt 0 ]; do
sysctl "$1"
sed -i.bak "/^${1%%=*}=/{
h
s|=.*|=${1#*=}|
}
\${
x
/^\$/{
s||${1}|
H
}
x
}" /etc/sysctl.conf
shift
done
rm -f /etc/sysctl.conf.bak
}
set_loader_conf(){
# Set the FreeBSD bootloader options in /boot/loader.conf.
# The host will be rebooted if the file is changed.
# $1..$N = bootloader options (as "name=value" strings)
# The '|' character is unsupported within the option value.
[ "$BOXCONF_OS" = freebsd ] || bug 'set_loader_conf can only be used on FreeBSD'
while [ $# -gt 0 ]; do
grep -qxF "${1%%=*}=\"${1#*=}\"" /boot/loader.conf || BOXCONF_NEED_REBOOT=true
sed -i.bak "/^${1%%=*}=/{
h
s|=.*|=\"${1#*=}\"|
}
\${
x
/^\$/{
s||${1%%=*}=\"${1#*=}\"|
H
}
x
}" /boot/loader.conf
shift
done
rm -f /boot/loader.conf.bak
}
load_kernel_module(){
# Ensure the given kernel modules are loaded.
# $1..$N = module names
case $BOXCONF_OS in
freebsd)
while [ $# -gt 0 ]; do
kldstat -qn "$1" || kldload -v "$1"
shift
done
;;
*)
die "load_kernel_module unimplemented for ${BOXCONF_OS}"
;;
esac
}
|