-
Notifications
You must be signed in to change notification settings - Fork 2
/
up.sh
executable file
·68 lines (54 loc) · 1.54 KB
/
up.sh
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
# ./up.sh -e jail -j pgadmin4 -v `sysctl -n kern.osrelease | cut -d - -f 1`
MYDIR=$( dirname `realpath $0` )
set -e
. ${MYDIR}/config.conf
. ${MYDIR}/func.subr
set +e
cmd_string=
jobname_file="image-${jname}-${arch}-${ver}"
log_file="${LOG_DIR}/${jobname_file}-${log_date}.log"
[ -r ${LOG_DIR}/package_version_${jname} ] && rm -f ${LOG_DIR}/package_version_${jname}
if [ "${myarch}" != "${arch}" ]; then
echo "not native arch: ${myarch}/${arch}" >> ${log_file} 2>&1
exit 1
if [ -z "${target_arch}" ]; then
echo "empty target_arch" >> ${log_file} 2>&1
exit 1
fi
fi
cd ${MYDIR}
env_path="${MYDIR}/${emulator}/${jname}"
cbsd ${destroy_cmd} ${jname} > /dev/null 2>&1 || true
if [ ! -r "${env_path}/CBSDfile" ]; then
echo "no such templates here: ${env_path}/CBSDfile" >> ${log_file} 2>&1
exit 1
fi
echo "template found: ${env_path}/CBSDfile" >> ${log_file} 2>&1
# CBSDFile
[ -r /usr/jails/formfile/${jname}.sqlite ] && rm -f /usr/jails/formfile/${jname}.sqlite
cd ${env_path}
cmd_string="cbsd up ver=${ver}"
${cmd_string} >> ${log_file} 2>&1
ret=$?
cd ${MYDIR}
if [ ${ret} -ne 0 ]; then
echo "up failed: ${env_path}/CBSDfile" >> ${log_file} 2>&1
exit ${ret}
fi
jid=$( cbsd ${status_cmd} ${jname} 2>/dev/null )
ret=$?
if [ ${ret} -ne 1 ]; then
echo "no such jail: ${jname}" >> ${log_file} 2>&1
exit 1
fi
if [ "${jid}" = "0" ]; then
cbsd ${start_cmd} ${jname} >> ${log_file} 2>&1
sleep 10
jid=$( cbsd ${status_cmd} ${jname} 2>/dev/null )
if [ "${jid}" = "0" ]; then
echo "jail not started: ${jname}" >> ${log_file} 2>&1
exit 1
fi
fi
exit 0