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