usr.sbin/makefs: Sync with sys/vfs/hammer2
[dragonfly.git] / usr.bin / dsynth / mktemplate.sh
blob15aba84baa7f3b4e3497a5c9e47be72cf650d5e9
1 #!/bin/csh
3 # mktemplate systembase templatebase
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.
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.
17 if ( $#argv != 2 ) then
18 echo "bad argument count"
19 echo "mktemplate systembase templatebase"
20 exit 1
21 endif
23 set sysbase = $argv[1]
24 set template = $argv[2]
25 set nonomatch
27 echo "Creating template from $sysbase to $template"
29 mkdir -p $template
30 mkdir -m 1777 -p $template/tmp
31 mkdir -m 1777 -p $template/var/tmp
32 mkdir -p $template/etc
33 cp -Rp $sysbase/etc/. $template/etc
35 foreach i ( `(cd $sysbase; find /var -type d)` )
36 mkdir -p $template/$i
37 end
39 mkdir -p $template/var/mail
40 chown root:mail $template/var/mail
41 chmod 775 $template/var/mail
43 mkdir -p $template/var/games
44 chown root:games $template/var/games
45 chmod 775 $template/var/games
47 mkdir -p $template/var/msgs
48 chown daemon:wheel $template/var/msgs
50 # Delete sensitive data from /etc
52 # Delete timezone translation so all packages are built in
53 # GMT. Fixes at least one package build.
55 rm -f $template/etc/ssh/*key*
56 rm -f $template/etc/localtime
58 if ( -f $template/etc/master.passwd ) then
59 cat $sysbase/etc/master.passwd | \
60 sed -e 's/:[^:]*:/:\*:/1' > $template/etc/master.passwd
61 endif
63 mkdir -p $template/root
64 mkdir -p $template/usr/local/etc
65 mkdir -p $template/usr/local/etc/pkg
66 mkdir -p $template/usr/local/bin
67 mkdir -p $template/usr/local/sbin
68 mkdir -p $template/usr/local/lib
69 mkdir -p $template/var/run
71 cp /var/run/ld-elf.so.hints $template/var/run
73 #echo > $template/usr/local/etc/pkg.conf