xref: /dragonfly/usr.bin/dsynth/mktemplate.sh (revision 5667bed1)
1#!/bin/csh
2#
3# mktemplate systembase templatebase
4#
5# This creates the Template directory which will be copied onto the
6# target worker chroot/jail after various mounts.  The template itself
7# does not have any sub-mounts nor does it need to provide mount points,
8# those will be created in mount.c.  Most system directories such as /bin
9# will be null-mounted later and do not have to be provided by this script.
10#
11# But any directories with special perms, such as /tmp and /var/tmp, are
12# provided by the template, and it is also responsible for providing
13# a sanitized /etc.
14#
15#
16
17if ( $#argv != 2 ) then
18	echo "bad argument count"
19	echo "mktemplate systembase templatebase"
20	exit 1
21endif
22
23set sysbase = $argv[1]
24set template = $argv[2]
25
26echo "Creating template from $sysbase to $template"
27
28mkdir -p $template
29mkdir -m 1777 -p $template/tmp
30mkdir -m 1777 -p $template/var/tmp
31mkdir -p $template/etc
32cp -Rp $sysbase/etc/. $template/etc
33
34foreach i ( `(cd $sysbase; find /var -type d)` )
35	mkdir -p $template/$i
36end
37
38# Delete sensitive data from /etc
39#
40#
41rm -f $template/etc/ssh/*key*
42
43if ( -f $template/etc/master.passwd ) then
44	cat $sysbase/etc/master.passwd | \
45		sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd
46endif
47
48mkdir -p $template/root
49mkdir -p $template/usr/local/etc
50mkdir -p $template/usr/local/etc/pkg
51mkdir -p $template/usr/local/bin
52mkdir -p $template/usr/local/sbin
53mkdir -p $template/usr/local/lib
54mkdir -p $template/var/run
55
56cp /var/run/ld-elf.so.hints $template/var/run
57
58#echo > $template/usr/local/etc/pkg.conf
59