xref: /dragonfly/usr.bin/dsynth/mktemplate.sh (revision 91dc43dd)
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]
25set nonomatch
26
27echo "Creating template from $sysbase to $template"
28
29mkdir -p $template
30mkdir -m 1777 -p $template/tmp
31mkdir -m 1777 -p $template/var/tmp
32mkdir -p $template/etc
33cp -Rp $sysbase/etc/. $template/etc
34
35foreach i ( `(cd $sysbase; find /var -type d)` )
36	mkdir -p $template/$i
37end
38
39mkdir -p $template/var/mail
40chown root:mail $template/var/mail
41chmod 775 $template/var/mail
42
43mkdir -p $template/var/games
44chown root:games $template/var/games
45chmod 775 $template/var/games
46
47mkdir -p $template/var/msgs
48chown daemon:wheel $template/var/msgs
49
50# Delete sensitive data from /etc
51#
52# Delete timezone translation so all packages are built in
53# GMT.  Fixes at least one package build.
54#
55rm -f $template/etc/ssh/*key*
56rm -f $template/etc/localtime
57
58if ( -f $template/etc/master.passwd ) then
59	cat $sysbase/etc/master.passwd | \
60		sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd
61endif
62
63mkdir -p $template/root
64mkdir -p $template/usr/local/etc
65mkdir -p $template/usr/local/etc/pkg
66mkdir -p $template/usr/local/bin
67mkdir -p $template/usr/local/sbin
68mkdir -p $template/usr/local/lib
69mkdir -p $template/var/run
70
71cp /var/run/ld-elf.so.hints $template/var/run
72
73#echo > $template/usr/local/etc/pkg.conf
74