-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_bhyve_profiles
executable file
·53 lines (45 loc) · 1.05 KB
/
get_bhyve_profiles
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
#!/usr/local/bin/cbsd
#v12.0.6
MYARG="src"
MYOPTARG="clonos"
MYDESC="Show bhyve profiles"
ADDHELP="src can be: cloud, template or vm\n\
clonos=1 - indicate that we work with ClonOS-only template\n"
. ${subr}
clonos=0
. ${cbsdinit}
. ${system}
case "${src}" in
cloud)
cache_file="${tmpdir}/bhyve-cloud.json"
# at the moment cloud = template, alias
;;
template)
cache_file="${tmpdir}/bhyve-templates.json"
;;
vm)
cache_file="${tmpdir}/bhyve-vm.json"
src="iso"
;;
*)
err 1 "unknown src: ${src}, use: src=cloud, src=vm or src=template"
;;
esac
if [ -r ${cache_file} ]; then
cache_file_size=$( ${STAT_CMD} -f "%z" ${cache_file} 2>/dev/null )
else
cache_file_size=0
fi
if [ -r ${cache_file} -a ${cache_file_size} -gt 5 ]; then
${CAT_CMD} ${cache_file}
else
if [ ${clonos} -eq 1 ]; then
is_clonos_args="--is_clonos"
else
is_clonos_args=
fi
#compile_bhyve_profiles --workdir ${workdir} --${src} ${is_clonos_args} > ${cache_file}
/usr/local/bin/cbsd get-profiles src=${src} json=1 > ${cache_file}
${CAT_CMD} ${cache_file}
fi
exit 0