xref: /dragonfly/usr.bin/dsynth/mktemplate.sh (revision 91a0d926)
18e25f19bSMatthew Dillon#!/bin/csh
28e25f19bSMatthew Dillon#
38e25f19bSMatthew Dillon# mktemplate systembase templatebase
48e25f19bSMatthew Dillon#
58e25f19bSMatthew Dillon# This creates the Template directory which will be copied onto the
68e25f19bSMatthew Dillon# target worker chroot/jail after various mounts.  The template itself
78e25f19bSMatthew Dillon# does not have any sub-mounts nor does it need to provide mount points,
88e25f19bSMatthew Dillon# those will be created in mount.c.  Most system directories such as /bin
98e25f19bSMatthew Dillon# will be null-mounted later and do not have to be provided by this script.
108e25f19bSMatthew Dillon#
118e25f19bSMatthew Dillon# But any directories with special perms, such as /tmp and /var/tmp, are
128e25f19bSMatthew Dillon# provided by the template, and it is also responsible for providing
138e25f19bSMatthew Dillon# a sanitized /etc.
148e25f19bSMatthew Dillon#
158e25f19bSMatthew Dillon#
168e25f19bSMatthew Dillon
178e25f19bSMatthew Dillonif ( $#argv != 2 ) then
188e25f19bSMatthew Dillon	echo "bad argument count"
198e25f19bSMatthew Dillon	echo "mktemplate systembase templatebase"
208e25f19bSMatthew Dillon	exit 1
218e25f19bSMatthew Dillonendif
228e25f19bSMatthew Dillon
238e25f19bSMatthew Dillonset sysbase = $argv[1]
248e25f19bSMatthew Dillonset template = $argv[2]
25d2dd7802SMatthew Dillonset nonomatch
268e25f19bSMatthew Dillon
278e25f19bSMatthew Dillonecho "Creating template from $sysbase to $template"
288e25f19bSMatthew Dillon
298e25f19bSMatthew Dillonmkdir -p $template
308e25f19bSMatthew Dillonmkdir -m 1777 -p $template/tmp
318e25f19bSMatthew Dillonmkdir -m 1777 -p $template/var/tmp
328e25f19bSMatthew Dillonmkdir -p $template/etc
338e25f19bSMatthew Dilloncp -Rp $sysbase/etc/. $template/etc
348e25f19bSMatthew Dillon
358e25f19bSMatthew Dillonforeach i ( `(cd $sysbase; find /var -type d)` )
368e25f19bSMatthew Dillon	mkdir -p $template/$i
378e25f19bSMatthew Dillonend
388e25f19bSMatthew Dillon
39534bbbacSMatthew Dillonmkdir -p $template/var/mail
40534bbbacSMatthew Dillonchown root:mail $template/var/mail
41534bbbacSMatthew Dillonchmod 775 $template/var/mail
42534bbbacSMatthew Dillon
43534bbbacSMatthew Dillonmkdir -p $template/var/games
44534bbbacSMatthew Dillonchown root:games $template/var/games
45534bbbacSMatthew Dillonchmod 775 $template/var/games
46534bbbacSMatthew Dillon
47534bbbacSMatthew Dillonmkdir -p $template/var/msgs
48534bbbacSMatthew Dillonchown daemon:wheel $template/var/msgs
49534bbbacSMatthew Dillon
508e25f19bSMatthew Dillon# Delete sensitive data from /etc
518e25f19bSMatthew Dillon#
52*91a0d926SMatthew Dillon# Delete timezone translation so all packages are built in
53*91a0d926SMatthew Dillon# GMT.  Fixes at least one package build.
548e25f19bSMatthew Dillon#
558e25f19bSMatthew Dillonrm -f $template/etc/ssh/*key*
56*91a0d926SMatthew Dillonrm -f $template/etc/localtime
578e25f19bSMatthew Dillon
588e25f19bSMatthew Dillonif ( -f $template/etc/master.passwd ) then
598e25f19bSMatthew Dillon	cat $sysbase/etc/master.passwd | \
608e25f19bSMatthew Dillon		sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd
618e25f19bSMatthew Dillonendif
628e25f19bSMatthew Dillon
638e25f19bSMatthew Dillonmkdir -p $template/root
648e25f19bSMatthew Dillonmkdir -p $template/usr/local/etc
658e25f19bSMatthew Dillonmkdir -p $template/usr/local/etc/pkg
668e25f19bSMatthew Dillonmkdir -p $template/usr/local/bin
678e25f19bSMatthew Dillonmkdir -p $template/usr/local/sbin
688ec23ca1SMatthew Dillonmkdir -p $template/usr/local/lib
698e25f19bSMatthew Dillonmkdir -p $template/var/run
708e25f19bSMatthew Dillon
718e25f19bSMatthew Dilloncp /var/run/ld-elf.so.hints $template/var/run
728e25f19bSMatthew Dillon
738e25f19bSMatthew Dillon#echo > $template/usr/local/etc/pkg.conf
74