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] 25*d2dd7802SMatthew 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# 528e25f19bSMatthew Dillon# 538e25f19bSMatthew Dillonrm -f $template/etc/ssh/*key* 548e25f19bSMatthew Dillon 558e25f19bSMatthew Dillonif ( -f $template/etc/master.passwd ) then 568e25f19bSMatthew Dillon cat $sysbase/etc/master.passwd | \ 578e25f19bSMatthew Dillon sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd 588e25f19bSMatthew Dillonendif 598e25f19bSMatthew Dillon 608e25f19bSMatthew Dillonmkdir -p $template/root 618e25f19bSMatthew Dillonmkdir -p $template/usr/local/etc 628e25f19bSMatthew Dillonmkdir -p $template/usr/local/etc/pkg 638e25f19bSMatthew Dillonmkdir -p $template/usr/local/bin 648e25f19bSMatthew Dillonmkdir -p $template/usr/local/sbin 658ec23ca1SMatthew Dillonmkdir -p $template/usr/local/lib 668e25f19bSMatthew Dillonmkdir -p $template/var/run 678e25f19bSMatthew Dillon 688e25f19bSMatthew Dilloncp /var/run/ld-elf.so.hints $template/var/run 698e25f19bSMatthew Dillon 708e25f19bSMatthew Dillon#echo > $template/usr/local/etc/pkg.conf 71