Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# |
3 |
# $FreeBSD$ |
4 |
# |
5 |
|
6 |
# PROVIDE: %%NAME%% |
7 |
# REQUIRE: LOGIN |
8 |
# KEYWORD: shutdown |
9 |
|
10 |
# Add the following lines to /etc/rc.conf to enable `%%NAME%%': |
11 |
# |
12 |
# %%NAME%%_enable="YES" |
13 |
# |
14 |
|
15 |
. /etc/rc.subr |
16 |
|
17 |
name=%%NAME%% |
18 |
rcvar=%%NAME%%_enable |
19 |
|
20 |
# read configuration and set defaults |
21 |
load_rc_config "$name" |
22 |
|
23 |
: ${%%NAME%%_enable:="NO"} |
24 |
|
25 |
BINMISCCTL=/usr/sbin/binmiscctl |
26 |
QEMU_DIR=%%PREFIX%%/bin |
27 |
QEMU_PREFIX=qemu- |
28 |
QEMU_SUFFIX=-static |
29 |
|
30 |
start_cmd=%%NAME%%_start |
31 |
stop_cmd=%%NAME%%_stop |
32 |
extra_commands=list |
33 |
list_cmd="${BINMISCCTL} list" |
34 |
|
35 |
%%NAME%%_start() |
36 |
{ |
37 |
# register arm interpreter styled 'arm' |
38 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX} |
39 |
if [ -x "${interpreter}" ]; then |
40 |
${BINMISCCTL} add arm --interpreter "${interpreter}" \ |
41 |
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \ |
42 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \ |
43 |
--size 20 --set-enabled |
44 |
else |
45 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
46 |
fi |
47 |
# register armv6 interpreter styled 'arm' |
48 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX} |
49 |
if [ -x "${interpreter}" ]; then |
50 |
${BINMISCCTL} add armv6 --interpreter "${interpreter}" \ |
51 |
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \ |
52 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \ |
53 |
--size 20 --set-enabled |
54 |
else |
55 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
56 |
fi |
57 |
# register armv7 interpreter styled 'arm' |
58 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX} |
59 |
if [ -x "${interpreter}" ]; then |
60 |
${BINMISCCTL} add armv7 --interpreter "${interpreter}" \ |
61 |
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \ |
62 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \ |
63 |
--size 20 --set-enabled |
64 |
else |
65 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
66 |
fi |
67 |
# register aarch64 interpreter styled 'aarch64' |
68 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}aarch64${QEMU_SUFFIX} |
69 |
if [ -x "${interpreter}" ]; then |
70 |
${BINMISCCTL} add aarch64 --interpreter "${interpreter}" \ |
71 |
--magic "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00" \ |
72 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \ |
73 |
--size 20 --set-enabled |
74 |
else |
75 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
76 |
fi |
77 |
# register mips interpreter styled 'mips' |
78 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mips${QEMU_SUFFIX} |
79 |
if [ -x "${interpreter}" ]; then |
80 |
${BINMISCCTL} add mips --interpreter "${interpreter}" \ |
81 |
--magic "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08" \ |
82 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
83 |
--size 20 --set-enabled |
84 |
else |
85 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
86 |
fi |
87 |
# register mipsle interpreter styled 'mipsel' |
88 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mipsel${QEMU_SUFFIX} |
89 |
if [ -x "${interpreter}" ]; then |
90 |
${BINMISCCTL} add mipsel --interpreter "${interpreter}" \ |
91 |
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00" \ |
92 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
93 |
--size 20 --set-enabled |
94 |
else |
95 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
96 |
fi |
97 |
# register mips64 interpreter styled 'mips64' |
98 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mips64${QEMU_SUFFIX} |
99 |
if [ -x "${interpreter}" ]; then |
100 |
${BINMISCCTL} add mips64 --interpreter "${interpreter}" \ |
101 |
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08" \ |
102 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
103 |
--size 20 --set-enabled |
104 |
else |
105 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
106 |
fi |
107 |
# register powerpc interpreter styled 'ppc' |
108 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}ppc${QEMU_SUFFIX} |
109 |
if [ -x "${interpreter}" ]; then |
110 |
${BINMISCCTL} add powerpc --interpreter "${interpreter}" \ |
111 |
--magic "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14" \ |
112 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
113 |
--size 20 --set-enabled |
114 |
else |
115 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
116 |
fi |
117 |
# register powerpc64 interpreter styled 'ppc64' |
118 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}ppc64${QEMU_SUFFIX} |
119 |
if [ -x "${interpreter}" ]; then |
120 |
${BINMISCCTL} add powerpc64 --interpreter "${interpreter}" \ |
121 |
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15" \ |
122 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
123 |
--size 20 --set-enabled |
124 |
else |
125 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
126 |
fi |
127 |
# register riscv64 interpreter styled 'riscv64' |
128 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}riscv64${QEMU_SUFFIX} |
129 |
if [ -x "${interpreter}" ]; then |
130 |
${BINMISCCTL} add riscv64 --interpreter "${interpreter}" \ |
131 |
--magic "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00" \ |
132 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \ |
133 |
--size 20 --set-enabled |
134 |
else |
135 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
136 |
fi |
137 |
# register sparc64 interpreter styled 'sparc64' |
138 |
interpreter=${QEMU_DIR}/${QEMU_PREFIX}sparc64${QEMU_SUFFIX} |
139 |
if [ -x "${interpreter}" ]; then |
140 |
${BINMISCCTL} add sparc64 --interpreter "${interpreter}" \ |
141 |
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b" \ |
142 |
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \ |
143 |
--size 20 --set-enabled |
144 |
else |
145 |
echo "$0: interpreter ${interpreter} not found, cannot register." |
146 |
fi |
147 |
} |
148 |
|
149 |
%%NAME%%_stop() |
150 |
{ |
151 |
${BINMISCCTL} remove arm |
152 |
${BINMISCCTL} remove armv6 |
153 |
${BINMISCCTL} remove armv7 |
154 |
${BINMISCCTL} remove aarch64 |
155 |
${BINMISCCTL} remove mips |
156 |
${BINMISCCTL} remove mips64 |
157 |
${BINMISCCTL} remove mipsel |
158 |
${BINMISCCTL} remove powerpc |
159 |
${BINMISCCTL} remove powerpc64 |
160 |
${BINMISCCTL} remove riscv64 |
161 |
${BINMISCCTL} remove sparc64 |
162 |
} |
163 |
|
164 |
run_rc_command "$1" |