-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvm_bootcfg
executable file
·77 lines (63 loc) · 2.06 KB
/
vm_bootcfg
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
69
70
71
72
73
74
75
76
77
#!/usr/local/bin/cbsd
#v11.1.19
MYARG="jname ip4_addr"
MYOPTARG="gw mask nameserver authkey authuser"
MYDESC="Configure first/primary settings for ConvectIX VM Appliance"
ADDHELP="authkey - path to authorized_keys to store inside vm. Can be: node\n\
authuser - store authkey inside authuser homedir. Default is: root\n\
ip4_addr can be: DHCP or REALDHCP\n"
CBSDMODULE="convectix"
. ${subr}
. ${cbsdinit}
. ${system}
. ${subrdir}/universe.subr
. ${subrdir}/bhyve.subr
orig_ip4_addr="${ip4_addr}"
case "${orig_ip4_addr}" in
[Rr][Ee][Aa][Ll][Dd][Hh][Cc][Pp])
mask=0
orig_mask=0
;;
[Dd][Hh][Cc][Pp])
mask=0
orig_mask=0
;;
*)
[ -z "${gw}" ] && err 1 "${N1_COLOR}gw= is mandatory${N0_COLOR}"
[ -z "${mask}" ] && err 1 "${N1_COLOR}mask= is mandatory${N0_COLOR}"
orig_gw="${gw}"
orig_mask="${mask}"
;;
esac
. ${jrcconf}
[ $? -eq 1 ] && err 1 "${N1_COLOR}Not found: ${N2_COLOR}${jname}${N0_COLOR}"
[ "${emulator}" != "bhyve" ] && err 1 "${N1_COLOR}Not in bhyve mode${N0_COLOR}"
dsk_path="${jaildatadir}/${jname}-${jaildatapref}"
system_dsk_path="${dsk_path}/cbsd.img"
[ ! -d ${dsk_path} ] && /bin/mkdir -p ${dsk_path}
readconf freecloud.conf
if [ -z "${convectix_ssh_pubkey}" ]; then
_md5name=$( /sbin/md5 -qs ${nodename} )
_keyfile="${sshdir}/${_md5name}.id_rsa"
convectix_ssh_pubkey="${sshdir}/authorized_keys"
fi
#[ ! -f ${convectix_ssh_pubkey} ] && err 1 "${N1_COLOR}Unable to read pubkey: ${N2_COLOR}${convectix_ssh_pubkey}${N0_COLOR}"
[ -z "${nameserver}" ] && nameserver="8.8.8.8,8.8.4.4"
[ -z "${authuser}" ] && authuser="root"
read_authkey=
[ "${authkey}" = "node" ] && read_authkey="${convectix_ssh_pubkey}"
[ -n "${authkey}" ] && read_authauthkey="${authkey}"
[ -n "${read_authkey}" -a -r "${read_authkey}" ] && authkey=$( ${CAT_CMD} ${read_authkey} )
${CAT_CMD} > ${system_dsk_path} <<CEOF
#!/bin/sh
cat > /etc/crsh/network.txt <<EOF
ip4_addr="${orig_ip4_addr}"
netmask="${orig_mask}"
gw="${orig_gw}"
nameserver="${nameserver}"
authuser="${authuser}"
authkey="${authkey}"
EOF
CEOF
bset jname=${jname} ip4_addr="${orig_ip4_addr}"
${TRUNCATE_CMD} -s1m ${system_dsk_path}