forked from cbsd/cbsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreebsd_world.subr
60 lines (52 loc) · 2.56 KB
/
freebsd_world.subr
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
# copy data from base, apply templates
# required: ver, baserw, data, BASE_DIR
populate_freebsd_world()
{
[ "${ver}" = "empty" ] && return 0
if [ "${baserw}" = "1" ]; then
#BASE_DIR variable from get_base
if ! populate_cdir ${BASE_DIR} ${data}; then
[ "${mdsize}" != "0" ] && cbsd unmountmd jroot=${data}
err 1 "Can't populate $data from $BASE_DIR"
fi
else
cp -rP ${BASE_DIR}/etc ${data}/
cp -rP ${BASE_DIR}/root ${data}/
[ -f "${BASE_DIR}/etc/mtree/BSD.root.dist" ] && mtree -deU -f ${BASE_DIR}/etc/mtree/BSD.root.dist -p ${data} >/dev/null
[ -f "${BASE_DIR}/etc/mtree/BSD.usr.dist" ] && mtree -deU -f ${BASE_DIR}/etc/mtree/BSD.usr.dist -p ${data}/usr >/dev/null
[ -f "${BASE_DIR}/etc/mtree/BSD.var.dist" ] && mtree -deU -f ${BASE_DIR}/etc/mtree/BSD.var.dist -p ${data}/var >/dev/null
# in FreeBSD10 BIND is go away
if [ -f "${BASE_DIR}/etc/mtree/BIND.chroot.dist" ]; then
[ ! -d "${data}/var/named" ] && mkdir ${data}/var/named
mtree -deU -f ${BASE_DIR}/etc/mtree/BIND.chroot.dist -p ${data}/var/named >/dev/null
fi
[ -f "${BASE_DIR}/etc/mtree/BSD.sendmail.dist" ] && mtree -deU -f ${BASE_DIR}/etc/mtree/BSD.sendmail.dist -p ${data} >/dev/null
fi
touch "${data}/etc/fstab"
[ ! -d ${data}/usr/home ] && mkdir ${data}/usr/home
[ ! -d ${data}/usr/local ] && mkdir ${data}/usr/local
[ ! -d ${data}/usr/compat ] && mkdir ${data}/usr/compat
[ ! -d ${data}/usr/ports ] && mkdir ${data}/usr/ports
[ ! -d ${data}/usr/local/etc ] && mkdir -p ${data}/usr/local/etc
if [ ${applytpl} -eq 1 ]; then
touch ${data}/etc/src.conf
if [ -d "${jailskeldir}" ]; then
${ECHO} "${MAGENTA}Applying skel dir template from: ${GREEN}${jailskeldir}${NORMAL}"
cd ${jailskeldir} && find -E ${jailskeldir} \( -type f -or -type d -or -type l \) -print |sed s:${jailskeldir}:./:g |cpio -pdmu ${data} > /dev/null 2>&1
else
${ECHO} "${MAGENTA}Skel dir template not found: ${GREEN}${jailskeldir}${NORMAL}"
fi
if [ -f ${data}/master.passwd ]; then
/usr/sbin/pwd_mkdb -d ${data}/etc ${data}/etc/master.passwd
fi
[ ! -f "${data}/etc/localtime" -a -f /etc/localtime ] && cp /etc/localtime ${data}/etc
fi
if [ -n "${customskel}" ]; then
if [ -d "${customskel}" ]; then
$ECHO "${MAGENTA}Applying custom skel dir template from: ${GREEN}${customskel}${NORMAL}"
cd ${customskel} && find -E ${customskel} \( -type f -or -type d -or -type l \) -print |sed s:${customskel}:./:g |cpio -pdmu ${data} > /dev/null 2>&1
else
${ECHO} "${MAGENTA}customskel dir specified but not found: ${GREEN}${customskel}${NORMAL}"
fi
fi
}