xref: /freebsd/tools/tools/nanobsd/rescue/common (revision f552d7ad)
1#
2#
3NANO_SRC=$(pwd)
4NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/rescue}
5NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj
6NANO_TOOLS=`pwd`
7NANO_PACKAGE_DIR=`pwd`/Pkg
8NANO_RAM_TMPVARSIZE=40960
9NANO_PMAKE="make -j 8"
10NANO_LABEL="rescue"
11NANO_RAM_TMPVARSIZE=40960
12NANO_MEDIASIZE="3932160"
13NANO_SECTS="63"
14NANO_HEADS="16"
15NANO_IMAGES="2"
16NANO_INIT_IMG2="0"
17NANO_BOOT0CFG="-o packet,update,nosetdrv -s 1 -m 3"
18NANO_DRIVE=da0
19#NANO_MODULES=
20NANO_BOOTLOADER="boot/boot0"
21NANO_BOOT2CFG=""
22NANO_MD_BACKING=file
23
24# Options to put in make.conf during buildworld only
25CONF_BUILD='
26'
27# Options to put in make.conf during installworld only
28CONF_INSTALL='
29'
30# Options to put in make.conf during both build- & installworld.
31CONF_WORLD='
32CFLAGS=-O -pipe
33# We do not need these for rescue
34WITHOUT_LIB32=true
35WITHOUT_TESTS=true
36WITHOUT_DEBUG_FILES=t
37WITHOUT_KERNEL_SYMBOLS=t
38'
39
40# Functions
41toLower() {
42  echo $1 | tr "[:upper:]" "[:lower:]"
43}
44
45toUpper() {
46  echo $1 | tr "[:lower:]" "[:upper:]"
47}
48
49#customize_cmd cust_comconsole
50customize_cmd cust_allow_ssh_root
51customize_cmd cust_install_files
52
53cust_ld32_cfg () (
54	cd ${NANO_WORLDDIR}/libexec
55	if [ \! -f ld-elf32.so.1 ]; then
56	ln -s ld-elf.so.1 ld-elf32.so.1
57	fi
58)
59customize_cmd cust_ld32_cfg
60
61#cust_boot_cfg () (
62#	cd ${NANO_WORLDDIR}
63#	echo "-S115200 -h" > boot.config
64#	echo "console=\"comconsole\"" > boot/loader.conf
65#	echo "comconsole_speed=\"115200\"" >> boot/loader.conf
66#	echo "hint.acpi.0.disabled=\"1\"" >> boot/loader.conf
67#)
68#customize_cmd cust_boot_cfg
69
70customize_cmd cust_pkgng
71
72cust_etc_cfg () (
73  cd ${NANO_WORLDDIR}
74#  mkdir -pv scratch
75	echo "hostname=\"rescue\"" > etc/rc.conf
76	echo "font8x14=\"iso15-8x14\"" >> etc/rc.conf
77	echo "font8x16=\"iso15-8x16\"" >> etc/rc.conf
78	echo "font8x8=\"iso15-8x8\"" >> etc/rc.conf
79	echo "keymap=\"german.iso\"" >> etc/rc.conf
80	echo "#ifconfig_fxp0=\"AUTO\"" >> etc/rc.conf
81	echo "#sshd_enable=\"YES\"" >> etc/rc.conf
82	echo "/dev/ufs/${NANO_LABEL}s1a / ufs ro,noatime 0 0" > etc/fstab
83	echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab
84	echo "tmpfs /boot/zfs tmpfs rw,size=1048576,mode=777 0 0" >> etc/fstab
85	echo "ports:/usr/ports /usr/ports nfs rw,noauto,noatime,bg,soft,intr,nfsv3 0 0" >> etc/fstab
86#	echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab
87	/usr/sbin/pwd_mkdb -d etc etc/master.passwd
88)
89customize_cmd cust_etc_cfg
90
91setup_nanobsd_etc ( ) (
92	pprint 2 "configure nanobsd /etc"
93	(
94	cd ${NANO_WORLDDIR}
95	# create diskless marker file
96	touch etc/diskless
97	# Make root filesystem R/O by default
98	echo "root_rw_mount=NO" >> etc/defaults/rc.conf
99	# save config file for scripts
100	echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
101	mkdir -p cfg
102	)
103)
104last_orders () (
105	pprint 2 "last orders"
106	(
107	cd ${NANO_WORLDDIR}
108	#makefs converts labels to uppercase anyways
109	BIGLABEL=`toUpper "${NANO_LABEL}"`
110	echo "/dev/iso9660/${BIGLABEL} / cd9660 ro,noatime 0 0" > etc/fstab
111	echo "tmpfs /boot/zfs tmpfs rw,size=1048576,mode=777 0 0" >> etc/fstab
112	echo "ports:/usr/ports /usr/ports nfs rw,noauto,noatime,bg,soft,intr,nfsv3 0 0" >> etc/fstab
113#	echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab
114	rm -f conf/default/etc/remount
115	touch conf/default/etc/.keepme
116	touch conf/default/var/.keepme
117	mkdir bootpool
118	mkdir mnt/a
119	mkdir mnt/b
120	mkdir mnt/c
121	cd ..
122	makefs -t cd9660 -o rockridge \
123	-o label="${BIGLABEL}" -o publisher="RMX" \
124	-o bootimage="i386;_.w/boot/cdboot" -o no-emul-boot _.disk.iso _.w/
125	)
126)
127