usermode.conf revision 1.3 1 1.3 christos # $NetBSD: usermode.conf,v 1.3 2013/02/03 09:16:25 christos Exp $
2 1.1 christos # NetBSD/usermode customization script used by mkimage
3 1.3 christos
4 1.3 christos # XXX: BROKEN, needs to be converted to makefs
5 1.1 christos custom=custom
6 1.1 christos image=usermode.img
7 1.1 christos overhead=8 # in MB
8 1.1 christos sets="base etc modules"
9 1.1 christos setsdir=/usr/build/release/$(uname -m)/binary/sets
10 1.1 christos size=0 # in MB
11 1.1 christos specialdirs="/kern /proc"
12 1.1 christos usermodedirs="/var.cow /etc.cow /root.cow /pkgs"
13 1.1 christos
14 1.1 christos make_filesystems() {
15 1.3 christos newfs /dev/r${vnddev}a
16 1.3 christos mount /dev/${vnddev}a ${mnt}
17 1.1 christos }
18 1.1 christos
19 1.1 christos make_fstab() {
20 1.3 christos cat > ${mnt}/etc/fstab << EOF
21 1.1 christos # NetBSD/usermode /etc/fstab
22 1.1 christos /dev/ld0a / ffs ro 1 1
23 1.1 christos /dev/ld1a /pkgs ffs ro 1 2
24 1.1 christos kernfs /kern kernfs rw
25 1.1 christos ptyfs /dev/pts ptyfs rw
26 1.1 christos procfs /proc procfs rw
27 1.1 christos # mount /root as tmpfs on top of existing dir
28 1.1 christos tmpfs /root.cow tmpfs rw,-s2M 0 0
29 1.1 christos /root.cow /root union rw,hidden 0 0
30 1.1 christos # mount /etc as tmpfs on top of existing dir
31 1.1 christos tmpfs /etc.cow tmpfs rw,-s12M 0 0
32 1.1 christos /etc.cow /etc union rw,hidden 0 0
33 1.1 christos # mount /var as tmpfs on top of existing dir
34 1.1 christos tmpfs /var.cow tmpfs rw,-s32M 0 0
35 1.1 christos /var.cow /var union rw,hidden - -
36 1.1 christos tmpfs /tmp tmpfs rw,-s32M 0 0
37 1.1 christos /dev/cd0a /cdrom cd9660 ro,noauto
38 1.1 christos EOF
39 1.1 christos }
40 1.1 christos
41 1.1 christos customize() {
42 1.3 christos cat >> ${mnt}/etc/rc.conf << EOF
43 1.1 christos # make sure we have the right rw filesystem at boot
44 1.1 christos critical_filesystems_local="/var.cow /var /etc.cow /etc /root.cow /root"
45 1.1 christos
46 1.1 christos # Add local overrides below
47 1.1 christos #
48 1.1 christos dhcpcd=YES
49 1.1 christos sshd=YES
50 1.1 christos EOF
51 1.1 christos
52 1.1 christos echo "${bar} making extra directories ${bar}"
53 1.1 christos for d in ${usermodedirs}; do
54 1.3 christos mkdir -p ${mnt}/${d}
55 1.1 christos done
56 1.1 christos
57 1.1 christos echo "${bar} customising /var/tmp ${bar}"
58 1.3 christos rm -rf ${mnt}/var/tmp
59 1.3 christos (cd ${mnt}/var && ln -s /tmp tmp)
60 1.1 christos
61 1.1 christos # package-related stuff
62 1.1 christos (cat ${mnt}/etc/csh.cshrc;echo "setenv PKG_DBDIR /usr/pkg/.dbdir") > ${tmp}
63 1.3 christos mv ${tmp} ${mnt}/etc/csh.cshrc
64 1.1 christos (cat ${mnt}/etc/profile;echo "export PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
65 1.3 christos mv ${tmp} ${mnt}/etc/profile
66 1.1 christos (echo "PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
67 1.3 christos mv ${tmp} ${mnt}/etc/mk.conf
68 1.3 christos (cd ${mnt}/usr && ln -s /pkgs/usr/pkg pkg)
69 1.1 christos
70 1.1 christos # last, customisation stage
71 1.1 christos if [ -d ${custom} ]; then
72 1.1 christos echo "${bar} user customisations from files in ${custom} ${bar}"
73 1.3 christos (cd ${custom} && pax -rwpe . ${mnt})
74 1.1 christos fi
75 1.1 christos
76 1.1 christos df ${mnt}
77 1.1 christos }
78 1.1 christos
79 1.1 christos cleanup() {
80 1.1 christos }
81