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# 53rm -f $template/etc/ssh/*key* 54 55if ( -f $template/etc/master.passwd ) then 56 cat $sysbase/etc/master.passwd | \ 57 sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd 58endif 59 60mkdir -p $template/root 61mkdir -p $template/usr/local/etc 62mkdir -p $template/usr/local/etc/pkg 63mkdir -p $template/usr/local/bin 64mkdir -p $template/usr/local/sbin 65mkdir -p $template/usr/local/lib 66mkdir -p $template/var/run 67 68cp /var/run/ld-elf.so.hints $template/var/run 69 70#echo > $template/usr/local/etc/pkg.conf 71