Home | History | Annotate | Line # | Download | only in conf
      1  1.7  riastrad # $NetBSD: usermode.conf,v 1.7 2023/09/27 00:24:13 riastradh 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 usermodedirs="/var.cow /etc.cow /root.cow /pkgs"
     12  1.1  christos 
     13  1.1  christos make_fstab() {
     14  1.3  christos cat > ${mnt}/etc/fstab << EOF
     15  1.1  christos # NetBSD/usermode /etc/fstab
     16  1.1  christos /dev/ld0a       /               ffs     ro              1 1
     17  1.1  christos /dev/ld1a	/pkgs		ffs	ro		1 2
     18  1.1  christos ptyfs           /dev/pts        ptyfs   rw
     19  1.1  christos procfs          /proc           procfs  rw
     20  1.1  christos # mount /root as tmpfs on top of existing dir
     21  1.1  christos tmpfs           /root.cow       tmpfs   rw,-s2M         0 0
     22  1.1  christos /root.cow       /root           union   rw,hidden       0 0
     23  1.1  christos # mount /etc as tmpfs on top of existing dir
     24  1.1  christos tmpfs           /etc.cow        tmpfs   rw,-s12M        0 0
     25  1.1  christos /etc.cow        /etc            union   rw,hidden       0 0
     26  1.1  christos # mount /var as tmpfs on top of existing dir
     27  1.1  christos tmpfs           /var.cow        tmpfs   rw,-s32M         0 0
     28  1.1  christos /var.cow        /var            union   rw,hidden       - -
     29  1.1  christos tmpfs           /tmp            tmpfs   rw,-s32M        0 0
     30  1.1  christos /dev/cd0a       /cdrom          cd9660  ro,noauto
     31  1.1  christos EOF
     32  1.1  christos }
     33  1.1  christos 
     34  1.1  christos customize() {
     35  1.3  christos cat >> ${mnt}/etc/rc.conf << EOF
     36  1.1  christos # make sure we have the right rw filesystem at boot
     37  1.1  christos critical_filesystems_local="/var.cow /var /etc.cow /etc /root.cow /root"
     38  1.1  christos 
     39  1.1  christos # Add local overrides below
     40  1.1  christos #
     41  1.1  christos dhcpcd=YES
     42  1.1  christos sshd=YES
     43  1.7  riastrad certctl_init=YES
     44  1.1  christos EOF
     45  1.1  christos 
     46  1.1  christos echo "${bar} making extra directories ${bar}"
     47  1.1  christos for d in ${usermodedirs}; do
     48  1.3  christos 	mkdir -p ${mnt}/${d}
     49  1.1  christos done
     50  1.1  christos 
     51  1.1  christos echo "${bar} customising /var/tmp ${bar}"
     52  1.3  christos rm -rf ${mnt}/var/tmp
     53  1.3  christos (cd ${mnt}/var && ln -s /tmp tmp)
     54  1.1  christos 
     55  1.1  christos # package-related stuff
     56  1.1  christos (cat ${mnt}/etc/csh.cshrc;echo "setenv PKG_DBDIR /usr/pkg/.dbdir") > ${tmp}
     57  1.3  christos mv ${tmp} ${mnt}/etc/csh.cshrc
     58  1.1  christos (cat ${mnt}/etc/profile;echo "export PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
     59  1.3  christos mv ${tmp} ${mnt}/etc/profile
     60  1.1  christos (echo "PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
     61  1.3  christos mv ${tmp} ${mnt}/etc/mk.conf
     62  1.3  christos (cd ${mnt}/usr && ln -s /pkgs/usr/pkg pkg)
     63  1.1  christos 
     64  1.1  christos # last, customisation stage
     65  1.1  christos if [ -d ${custom} ]; then
     66  1.1  christos 	echo "${bar} user customisations from files in ${custom} ${bar}"
     67  1.3  christos 	(cd ${custom} && pax -rwpe . ${mnt})
     68  1.1  christos fi
     69  1.1  christos 
     70  1.1  christos df ${mnt}
     71  1.1  christos }
     72  1.1  christos 
     73  1.1  christos cleanup() {
     74  1.1  christos }
     75