├── .cvsignore ├── Makefile ├── README.txt ├── lib ├── .cvsignore ├── 010_extract.sh ├── 020_modify_tree.sh ├── RDROOT.MP.amd64.diff ├── RDROOT.MP.arm64.diff ├── RDROOT.MP.i386.diff ├── RDROOT.amd64.diff ├── RDROOT.arm64.diff ├── RDROOT.diff ├── RDROOT.i386.diff ├── boot.conf.amd64 ├── boot.conf.arm64 ├── boot.conf.i386 ├── bootbin │ ├── Makefile │ ├── bootbin.conf.orig │ ├── bootbin.conf.orig.amd64 │ └── special │ │ ├── Makefile │ │ ├── init │ │ ├── .cvsignore │ │ └── Makefile │ │ ├── mount_ntfs │ │ ├── .cvsignore │ │ └── Makefile │ │ ├── mount_vnd │ │ ├── .cvsignore │ │ └── Makefile │ │ ├── newfs │ │ ├── .cvsignore │ │ └── Makefile │ │ ├── swapctl │ │ ├── .cvsignore │ │ └── Makefile │ │ ├── sysctl │ │ ├── .cvsignore │ │ └── Makefile │ │ └── vnconfig │ │ ├── .cvsignore │ │ └── Makefile ├── create_imgs.sh ├── fiopt │ └── Makefile ├── global.conf.amd64 ├── global.conf.arm64 ├── global.conf.i386 ├── makebootarc_arm64.sh ├── setup_fsimg.sh ├── tools │ ├── compress_man.sh │ ├── find1so.sh │ ├── gen_makebootarc_arm64.sh │ ├── guidtab.sh │ ├── listvars.pl │ └── setupfs └── usbfadm_postproc.sh.arm64 └── rdroot └── boottmp ├── LICENSE ├── chnetconf ├── dtjsetup ├── etc.login.conf.diff ├── etc.rc.diff ├── fdadm ├── fiupdate ├── gen_mode0sldir ├── gennetconfs ├── livecd-retr.sh.inc ├── mtree_special.mode0.diff ├── mtree_special.mode1.diff ├── mtree_special.mode2.diff ├── rc ├── remaster_dvd └── usbfadm /.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | FuguIta-*-*-*.iso.gz 3 | FuguIta-*-*-*.img.gz 4 | fuguita 5 | install_patches 6 | install_pkgs 7 | install_sets 8 | livecd.iso 9 | rdroot.ffsimg 10 | rev.count 11 | staging 12 | staging.time 13 | sync.time 14 | sys 15 | sysmedia 16 | sysmedia.img 17 | sysmedia.time 18 | sysmedia-*-*.img.gz 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2005--2025, Yoshihiro Kawamata 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in 13 | # the documentation and/or other materials provided with the 14 | # distribution. 15 | # 16 | # * Neither the name of the Yoshihiro Kawamata nor the names of its 17 | # contributors may be used to endorse or promote products derived 18 | # from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # $Id: Makefile,v 1.135 2025/04/05 07:57:29 kaw Exp $ 33 | 34 | #======================================== 35 | # global definitions 36 | # 37 | PROJNAME = FuguIta 38 | VERSION != uname -r 39 | VER != uname -r | tr -d . 40 | # e.g. VERSTAT=_cur 41 | VERSTAT = 42 | ARCH != uname -m 43 | DATE != date +%Y%m%d 44 | REV != if [[ -r rev.count ]] ; then\ 45 | rev=$$(cat rev.count);\ 46 | else\ 47 | rev=1;\ 48 | fi;\ 49 | [[ $$rev -le 0 ]] && rev=1;\ 50 | echo $$rev 51 | AUTHOR = Yoshihiro Kawamata 52 | FIBASE = $(VERSION)$(VERSTAT)-$(ARCH)-$(DATE)$(REV) 53 | FI ?= $(PROJNAME)-$(FIBASE) 54 | 55 | SYSMEDIA=sysmedia-$(VERSION)-$(ARCH) 56 | 57 | BLDDIR != realpath $$(pwd) 58 | 59 | KERNSRC = $(BLDDIR)/sys 60 | KERNOPT ?= -j2 61 | BSD_SP = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT/obj/bsd 62 | BSD_SPG = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT/obj/gapdummy.o 63 | BSD_SPV = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT/obj/vers.o 64 | BSD_MP = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT.MP/obj/bsd 65 | BSD_MPG = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT.MP/obj/gapdummy.o 66 | BSD_MPV = $(KERNSRC)/arch/$(ARCH)/compile/RDROOT.MP/obj/vers.o 67 | KERN_SP = $(BLDDIR)/sysmedia/bsd-fi 68 | KERN_MP = $(BLDDIR)/sysmedia/bsd-fi.mp 69 | 70 | COMPRESS ?= gzip 71 | 72 | # define and setup UEFI CD boot 73 | # if UEFI applications exist 74 | # 75 | .if exists(/usr/mdec/BOOTIA32.EFI) 76 | . if exists(/usr/mdec/BOOTX64.EFI) 77 | EFICD=1 78 | EFICDBOOT_SIZE=350K 79 | EFICD_OPT=-e eficdboot 80 | MAKE_EFICD=$(MAKE) sysmedia/eficdboot 81 | . endif 82 | .endif 83 | 84 | # dummy command for non-UEFI boot 85 | # 86 | .ifndef MAKE_EFICD 87 | MAKE_EFICD=true 88 | .endif 89 | 90 | # define CD boot for arm64 91 | # 92 | .if $(ARCH) == arm64 93 | . if exists(/usr/mdec/BOOTAA64.EFI) 94 | ARM64_ISO=1 95 | . endif 96 | .endif 97 | 98 | #======================================== 99 | # final target 100 | # 101 | .PHONY: all livedvd liveusb 102 | all: 103 | $(MAKE) livedvd 104 | $(MAKE) liveusb 105 | # increase revision 106 | echo $$(($(REV)+1)) > rev.count 107 | # to reorder kernel at next compilation 108 | $(MAKE) kernreset 109 | 110 | livedvd: $(FI).iso.gz 111 | liveusb: $(FI).img.gz 112 | 113 | # build an ISO image 114 | # 115 | $(FI).iso.gz: livecd.iso 116 | @echo generating $(FI).iso.gz 117 | pv livecd.iso | $(COMPRESS) -9f -c > $(FI).iso.gz 118 | 119 | # build a disk image 120 | # This needs sysmedia.img 121 | # 122 | .if exists(sysmedia.img) 123 | $(FI).img.gz: sysmedia.time 124 | $(MAKE) open-sysmedia 125 | $(MAKE) sysmedia/boot sysmedia/cdboot sysmedia/cdbr sysmedia/etc/boot.conf\ 126 | $(KERN_SP) $(KERN_MP)\ 127 | sysmedia/fuguita-$(VERSION)-$(ARCH).ffsimg 128 | $(MAKE_EFICD) 129 | $(MAKE) open-fuguita 130 | echo "$(FIBASE)" > fuguita/usr/fuguita/version 131 | $(MAKE) close-all 132 | @echo generating $(FI).img.gz 133 | pv sysmedia.img | $(COMPRESS) -9f -c > $(FI).img.gz 134 | .else 135 | $(FI).img.gz: 136 | @echo You need sysmedia.img to build $(FI).img.gz. 137 | .endif 138 | 139 | # sync staging to sysmedia/fuguita-*.ffsimg 140 | # 141 | .PHONY: sync 142 | sync: staging.time 143 | $(MAKE) open-fuguita 144 | # equalize fuguita directory to staging: 145 | # When applying a patch and resynchronizing, media.img may overflow, 146 | # so in that case, delete some large files and rerun rsync. 147 | cd staging &&\ 148 | if ! rsync -avxH --delete . ../fuguita/.; then\ 149 | find ../fuguita/ -type f -size +4096 -print | xargs rm;\ 150 | rsync -avxH --delete . ../fuguita/.;\ 151 | fi 152 | $(MAKE) close-fuguita 153 | 154 | # fill into sysmedia (or sysmedia.img) 155 | # 156 | sysmedia.time: 157 | $(MAKE) open-fuguita 158 | $(MAKE) sysmedia/boot sysmedia/cdboot sysmedia/cdbr sysmedia/etc/boot.conf\ 159 | $(KERN_SP) $(KERN_MP)\ 160 | sysmedia/fuguita-$(VERSION)-$(ARCH).ffsimg 161 | $(MAKE_EFICD) 162 | # fuguita closed in above rules, then reopen it 163 | $(MAKE) open-fuguita 164 | echo "$(FIBASE)" > fuguita/usr/fuguita/version 165 | $(MAKE) close-fuguita 166 | touch sysmedia.time 167 | 168 | # generate an ISO file 169 | # 170 | livecd.iso: sysmedia.time 171 | mkhybrid -a -R -L -l -d -D -N\ 172 | -o livecd.iso\ 173 | -v -v\ 174 | -A "FuguIta: OpenBSD-based Live System"\ 175 | -P "Copyright (c) `date +%Y` Yoshihiro Kawamata"\ 176 | -p "Yoshihiro Kawamata, https://fuguita.org/"\ 177 | -V "$(FI)"\ 178 | -b cdbr\ 179 | $(EFICD_OPT)\ 180 | -c boot.catalog\ 181 | sysmedia\ 182 | 183 | # on arm64, following boot loaders are not required 184 | # but null (dummy) files must be exist for usbfadm newdrive 185 | # 186 | .for bootstuff in boot cdboot 187 | . if exists($(bootstuff)) 188 | sysmedia/$(bootstuff): /usr/mdec/$(bootstuff) 189 | . else 190 | sysmedia/$(bootstuff): 191 | . endif 192 | # To keep the i-node number the same 193 | # so that the PBR does not lose sight of /boot 194 | -cat /usr/mdec/$(bootstuff) >sysmedia/$(bootstuff) 195 | .endfor 196 | 197 | # if an UEFI application for arm64 exists, create a cdbr 198 | # 199 | sysmedia/cdbr: 200 | .ifdef ARM64_ISO 201 | dd if=/dev/zero of=sysmedia/cdbr bs=512 count=5760 202 | vnconfig vnd3 sysmedia/cdbr 203 | fdisk -iy -b "5744@16:c" vnd3 204 | newfs -t msdos /dev/rvnd3i 205 | mkdir arm64cdboot 206 | mount -o-l /dev/vnd3i arm64cdboot 207 | mkdir -p arm64cdboot/efi/boot 208 | cp /usr/mdec/BOOTAA64.EFI arm64cdboot/efi/boot/bootaa64.efi 209 | echo bootaa64.efi > arm64cdboot/efi/boot/startup.nsh 210 | umount arm64cdboot 211 | vnconfig -u vnd3 212 | rmdir arm64cdboot 213 | .else 214 | -cat /usr/mdec/cdbr >sysmedia/cdbr 215 | .endif 216 | 217 | # create a UEFI boot image for amd64 if UEFI applications exist 218 | # 219 | .ifdef EFICD 220 | sysmedia/eficdboot: /usr/mdec/BOOTIA32.EFI /usr/mdec/BOOTX64.EFI 221 | rm -rf eficdboot 222 | mkdir -p eficdboot/efi/boot 223 | cp /usr/mdec/BOOTIA32.EFI /usr/mdec/BOOTX64.EFI eficdboot/efi/boot/. 224 | makefs -t msdos -o create_size=$(EFICDBOOT_SIZE) sysmedia/eficdboot eficdboot 225 | rm -rf eficdboot 226 | .endif 227 | 228 | sysmedia/etc/boot.conf: lib/boot.conf.$(ARCH) 229 | [ -d sysmedia/etc ] || mkdir sysmedia/etc 230 | cp lib/boot.conf.$(ARCH) sysmedia/etc/boot.conf 231 | 232 | # ffsimg's contents must be identical to staging's one 233 | # 234 | sysmedia/fuguita-$(VERSION)-$(ARCH).ffsimg: sync 235 | 236 | #======================================== 237 | # merging a RAM disk root filesystem image 238 | # into a kernel 239 | # 240 | $(KERN_SP): rdroot.ffsimg $(BSD_SP) 241 | $(MAKE) open-sysmedia 242 | cp $(BSD_SP) bsd 243 | rdsetroot bsd rdroot.ffsimg 244 | $(COMPRESS) -c9 bsd > $(KERN_SP) 245 | rm bsd 246 | $(MAKE) close-sysmedia 247 | 248 | $(KERN_MP): rdroot.ffsimg $(BSD_MP) 249 | $(MAKE) open-sysmedia 250 | cp $(BSD_MP) bsd.mp 251 | rdsetroot bsd.mp rdroot.ffsimg 252 | $(COMPRESS) -c9 bsd.mp > $(KERN_MP) 253 | rm bsd.mp 254 | $(MAKE) close-sysmedia 255 | 256 | #======================================== 257 | # stuffs on kernel compilation 258 | # 259 | .PHONY: kernconfig 260 | kernconfig: 261 | (cd $(KERNSRC)/conf &&\ 262 | cp GENERIC RDROOT &&\ 263 | patch < $(BLDDIR)/lib/RDROOT.diff) 264 | (cd $(KERNSRC)/arch/$(ARCH)/conf &&\ 265 | cp GENERIC RDROOT &&\ 266 | patch < $(BLDDIR)/lib/RDROOT.$(ARCH).diff &&\ 267 | cp GENERIC.MP RDROOT.MP &&\ 268 | patch < $(BLDDIR)/lib/RDROOT.MP.$(ARCH).diff &&\ 269 | config RDROOT && config RDROOT.MP) 270 | 271 | .PHONY: kernclean 272 | kernclean: 273 | (cd $(KERNSRC)/arch/$(ARCH)/compile/RDROOT &&\ 274 | make clean) 275 | (cd $(KERNSRC)/arch/$(ARCH)/compile/RDROOT.MP &&\ 276 | make clean) 277 | 278 | .PHONY: kern 279 | kern: $(BSD_SP) $(BSD_MP) 280 | 281 | $(BSD_SP): 282 | (cd $(KERNSRC)/arch/$(ARCH)/compile/RDROOT &&\ 283 | make $(KERNOPT)) 284 | 285 | $(BSD_MP): 286 | (cd $(KERNSRC)/arch/$(ARCH)/compile/RDROOT.MP &&\ 287 | make $(KERNOPT)) 288 | 289 | # reorder kernel at next compilation 290 | # 291 | .PHONY: kernreset 292 | kernreset: 293 | rm -f $(BSD_SP) $(BSD_SPG) $(BSD_SPV)\ 294 | $(BSD_MP) $(BSD_MPG) $(BSD_MPV) 295 | 296 | #======================================== 297 | # generating RAM disk root filesystem image 298 | # 299 | .if exists(rdroot/boottmp/rc) 300 | BOOTTMPS != echo rdroot/boottmp/* 301 | .endif 302 | 303 | rdroot.ffsimg: /usr/src/etc/etc.$(ARCH)/MAKEDEV\ 304 | /usr/src/etc/etc.$(ARCH)/login.conf\ 305 | lib/bootbin/obj/bootbin $(BOOTTMPS) 306 | $(MAKE) close-rdroot 307 | # 308 | # create rdroot.ffsimg 309 | # 310 | ./lib/setup_fsimg.sh rdroot.ffsimg 4M 1500 '-b 4096 -f 512' 311 | # parameters for minimum resources ^^^^^^^^^^^^^^ 312 | vnconfig vnd0 rdroot.ffsimg 313 | mount /dev/vnd0a /mnt 314 | (cd rdroot && pax -rwvpe . /mnt/.) 315 | # 316 | # setup inside rdroot.ffsimg 317 | # 318 | ln -sf boottmp /mnt/bin 319 | ln -sf boottmp /mnt/etc 320 | ln -sf boottmp /mnt/sbin 321 | mkdir -p /mnt/{dev,fuguita,mnt,ram,sysmedia,sysmedia-iso,tmp} 322 | chmod go-rwx /mnt/sysmedia-iso 323 | chmod 1777 /mnt/tmp 324 | cd /mnt/dev && cp -p /usr/src/etc/etc.$$(uname -m)/MAKEDEV . && sh ./MAKEDEV all vnd4 vnd5 325 | # datasize in login.conf determines the max limit of mfs 326 | sed '/^daemon:/,/:tc=default:/ s/:datasize=[^:][^:]*:/:datasize=infinity:/'\ 327 | /usr/src/etc/etc.$(ARCH)/login.conf > /mnt/boottmp/login.conf 328 | cp -p lib/bootbin/obj/bootbin /mnt/boottmp 329 | for prog in disklabel gzip halt init ln mount mount_cd9660 mount_ext2fs\ 330 | mount_ffs mount_mfs mount_msdos mount_ntfs mount_vnd newfs\ 331 | reboot sed sleep swapctl swapon sysctl umount vnconfig; do\ 332 | ln -f /mnt/boottmp/bootbin /mnt/boottmp/$$prog;\ 333 | done 334 | rm -f /mnt/boottmp/ksh /mnt/boottmp/sh 335 | cp -p /bin/ksh /mnt/boottmp/. 336 | ln /mnt/boottmp/ksh /mnt/boottmp/sh 337 | umount /mnt || { sync; sleep 15; sync; umount /mnt; } 338 | vnconfig -u vnd0 339 | 340 | # build a crunched binary 341 | # 342 | lib/bootbin/obj/bootbin: 343 | cd lib/bootbin;\ 344 | make 345 | 346 | #======================================== 347 | # vnconfig related stuffs 348 | # 349 | 350 | # to faster access 351 | # 352 | MNT_OPT = -o async,noatime 353 | 354 | .PHONY: open-rdroot 355 | open-rdroot: 356 | @if vnconfig -l | grep -q '^vnd0: not in use'; then\ 357 | vnconfig vnd0 rdroot.ffsimg;\ 358 | fi 359 | @if vnconfig -l | grep -q '^vnd0: covering ' &&\ 360 | ! mount | grep -q '^/dev/vnd0a on '; then\ 361 | mount $(MNT_OPT) /dev/vnd0a /mnt;\ 362 | fi 363 | 364 | .PHONY: close-rdroot 365 | close-rdroot: 366 | @if mount | grep -q '^/dev/vnd0a on '; then\ 367 | umount /dev/vnd0a || { sync; sleep 15; sync; umount /dev/vnd0a; };\ 368 | fi 369 | @if vnconfig -l | grep -q '^vnd0: covering '; then\ 370 | vnconfig -u vnd0;\ 371 | fi 372 | 373 | # if sysmedia.img exists , mount the vnode vnd1 bound to it. 374 | # otherwise, work in directory sysmedia 375 | # 376 | .PHONY: open-sysmedia 377 | open-sysmedia: 378 | @if [ -f sysmedia.img ];\ 379 | then\ 380 | if vnconfig -l | grep -q '^vnd1: not in use'; then\ 381 | vnconfig vnd1 sysmedia.img;\ 382 | fi;\ 383 | if vnconfig -l | grep -q '^vnd1: covering ' &&\ 384 | ! mount | grep -q '^/dev/vnd1a on '; then\ 385 | mount $(MNT_OPT) /dev/vnd1a $(BLDDIR)/sysmedia;\ 386 | fi;\ 387 | fi 388 | 389 | .PHONY: close-sysmedia 390 | close-sysmedia: close-fuguita 391 | @if [ -f sysmedia.img ];\ 392 | then\ 393 | if mount | grep -q '^/dev/vnd1a on '; then\ 394 | umount /dev/vnd1a || { sync; sleep 15; sync; umount /dev/vnd1a; };\ 395 | fi;\ 396 | if vnconfig -l | grep -q '^vnd1: covering '; then\ 397 | vnconfig -u vnd1;\ 398 | fi;\ 399 | fi 400 | 401 | .PHONY: open-fuguita 402 | open-fuguita: open-sysmedia 403 | @if vnconfig -l | grep -q '^vnd2: not in use'; then\ 404 | vnconfig vnd2 $(BLDDIR)/sysmedia/fuguita-$(VERSION)-$(ARCH).ffsimg;\ 405 | fi 406 | @if vnconfig -l | grep -q '^vnd2: covering ' &&\ 407 | ! mount | grep -q '^/dev/vnd2a on '; then\ 408 | mount $(MNT_OPT) /dev/vnd2a $(BLDDIR)/fuguita;\ 409 | fi 410 | 411 | .PHONY: close-fuguita 412 | close-fuguita: 413 | @if mount | grep -q '^/dev/vnd2a on '; then\ 414 | umount /dev/vnd2a || { sync; sleep 15; sync; umount /dev/vnd2a; };\ 415 | fi 416 | @if vnconfig -l | grep -q '^vnd2: covering '; then\ 417 | vnconfig -u vnd2;\ 418 | fi 419 | 420 | .PHONY: close-all 421 | close-all: 422 | -$(MAKE) close-rdroot 423 | -$(MAKE) close-sysmedia 424 | 425 | # create fundamental files and directories 426 | # 427 | .PHONY: init 428 | init: 429 | $(MAKE) reset 430 | mkdir -p sys install_sets install_pkgs install_patches fuguita sysmedia 431 | if [ ! -d sys/arch/$(ARCH) ]; then (cd sys && lndir /usr/src/sys); fi 432 | cd lib/bootbin;\ 433 | make obj;\ 434 | cd special;\ 435 | ln -sf /usr/src/distrib/special/Makefile.inc .;\ 436 | make obj 437 | .if exists($(SYSMEDIA).img.gz) 438 | pv $(SYSMEDIA).img.gz | $(COMPRESS) -d -c > sysmedia.img 439 | .endif 440 | 441 | # full compilation kernels 442 | # and setup for RAM disk filesystem image 443 | # 444 | .PHONY: setup 445 | setup: 446 | $(MAKE) kernconfig 447 | $(MAKE) kernclean 448 | $(MAKE) rdroot.ffsimg 449 | $(MAKE) imgs 450 | 451 | # creating media.img 452 | # and fuguita-REV-ARCH.ffsimg located in media.img (or media) 453 | # 454 | .PHONY: imgs 455 | .ifdef CREATE_SYSMEDIA_IMG 456 | # kernels are needed for get the size of media.img 457 | imgs: staging $(BSD_SP) $(BSD_MP) 458 | .else 459 | imgs: staging 460 | .endif 461 | ./lib/create_imgs.sh 462 | # an alternative under test 463 | # ./lib/setupfs.sh sysmedia/fuguita-$(VERSION)-$(ARCH).ffsimg staging 16m 464 | 465 | #======================================== 466 | # create staging directory 467 | # and file tree which is modified for the Live System 468 | # 469 | 470 | # set files under install_*/* 471 | # 472 | STAGE_DEPENDS = 473 | .for dir in install_sets install_pkgs install_patches 474 | files != ls $(dir) 2>/dev/null | grep -v '^\.' || true 475 | . for file in $(files) 476 | STAGE_DEPENDS += $(dir)/$(file) 477 | . endfor 478 | .endfor 479 | 480 | STAGE_DEPENDS += lib/global.conf.$(ARCH) 481 | 482 | .if exists(lib/mode0symlinks.cpio.gz.$(ARCH)) 483 | STAGE_DEPENDS += lib/mode0symlinks.cpio.gz.$(ARCH) 484 | .endif 485 | 486 | .if exists(lib/usbfadm_postproc.sh.$(ARCH)) 487 | STAGE_DEPENDS += lib/usbfadm_postproc.sh.$(ARCH) 488 | .endif 489 | 490 | .PHONY: staging 491 | staging: staging.time 492 | staging.time: $(STAGE_DEPENDS) 493 | ./lib/010_extract.sh 494 | ./lib/020_modify_tree.sh 495 | touch staging.time 496 | 497 | #======================================== 498 | # packaging controls 499 | # 500 | DISTCLEANFILES = rev.count sysmedia.img 501 | DISTCLEANDIRS = staging fuguita sysmedia sys install_sets install_pkgs install_patches 502 | 503 | .PHONY: distclean 504 | distclean: 505 | $(MAKE) clean 506 | $(MAKE) rdclean 507 | rm -f $(DISTCLEANFILES) 508 | rm -rf $(DISTCLEANDIRS) 509 | 510 | # reset revision sequece numnber to 1 511 | # 512 | .PHONY: reset 513 | reset: 514 | echo 1 > rev.count 515 | 516 | CLEANFILES = bsd bsd.mp livecd.iso sysmedia.time staging.time FuguIta-?.*-*-*.*.gz\ 517 | $(BSD_SP) $(BSD_MP) trial_capa.img 518 | CLEANDIRS = staging.*_* trial_capa eficdboot 519 | .PHONY: clean 520 | clean: 521 | $(MAKE) close-all 522 | rm -f $(CLEANFILES) 523 | rm -rf $(CLEANDIRS) 524 | 525 | # remove all requisites to build RAM disk filesystem image 526 | # 527 | .PHONY: rdclean 528 | rdclean: 529 | rm -rf rdroot.ffsimg 530 | cd lib/bootbin && rm -rf obj 531 | cd lib/bootbin/special && rm -f Makefile.inc 532 | cd lib/bootbin/special && rm -rf */obj 533 | 534 | #======================================== 535 | # generate LiveUSB from LiveDVD 536 | # 537 | IMGMB = 2048# size of uncompressed LiveUSB in MB 538 | 539 | .PHONY: dvd2usb 540 | dvd2usb: 541 | pv $(FI).iso.gz | $(COMPRESS) -d -c > $(FI).iso 542 | dd if=/dev/zero bs=1m count=$(IMGMB) | pv -s $(IMGMB)M > $(FI).img 543 | vmctl start -cL -i1 -m2G -r $(FI).iso -d $(FI).img fi74 544 | vmctl start -cL -i1 -m2G -d $(FI).img fi74 545 | pv $(FI).img | $(COMPRESS) -9 -c > $(FI).img.gz 546 | 547 | .PHONY: imgclean 548 | imgclean: 549 | rm -f $(FI).img.gz $(FI).img $(FI).iso 550 | 551 | #======================================== 552 | # generate blank disk image for LiveUSB 553 | # 554 | .PHONY: blank-img 555 | blank-img: $(SYSMEDIA).img.gz 556 | 557 | $(SYSMEDIA).img.gz: $(SYSMEDIA).img 558 | # initialize 559 | $(MAKE) close-all 560 | mkdir -p $(SYSMEDIA) 561 | vnconfig vnd1 $(SYSMEDIA).img 562 | mount /dev/vnd1a $(SYSMEDIA) 563 | [ -f $(SYSMEDIA)/boot ] 564 | # zerofill partition A 565 | # this is for possible smallest compressed image 566 | cd $(SYSMEDIA) && rm -rf !(boot) 567 | -dd if=/dev/zero bs=16m | pv -s $$(df -k | grep vnd1a | awk '{print $$2}')K > $(SYSMEDIA)/zerofill 568 | -cat $(SYSMEDIA)/zerofill >> $(SYSMEDIA)/zerofill 569 | rm -f $(SYSMEDIA)/zerofill 570 | umount $(SYSMEDIA) 571 | # zerofill partition D 572 | # this is for possible smallest compressed image 573 | mount /dev/vnd1d $(SYSMEDIA) 574 | -dd if=/dev/zero bs=16m | pv -s $$(df -k | grep vnd1d | awk '{print $$2}')K > $(SYSMEDIA)/zerofill 575 | -cat $(SYSMEDIA)/zerofill >> $(SYSMEDIA)/zerofill 576 | rm -f $(SYSMEDIA)/zerofill 577 | umount $(SYSMEDIA) 578 | vnconfig -u vnd1 579 | pv $(SYSMEDIA).img | $(COMPRESS) -c -9 > $(SYSMEDIA).img.gz 580 | 581 | $(SYSMEDIA).img: $(FI).img.gz 582 | pv $(FI).img.gz | $(COMPRESS) -d -c > $(SYSMEDIA).img 583 | 584 | .PHONY: blank-img-clean 585 | blank-img-clean: 586 | rm -f $(SYSMEDIA).img 587 | rm -rf $(SYSMEDIA) 588 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | FuguIta - The OpenBSD-based Live System 2 | 3 | Yoshihiro Kawamata 4 | 2025/04/19 5 | 6 | 7 | Table of Contents 8 | 9 | * What is FuguIta? 10 | ** Features 11 | *** Easy to use 12 | *** Tracking patches of OpenBSD 13 | *** Flexible Operation 14 | *** Utilize LiveUSB features 15 | *** Support tools provided 16 | *** Remastering and Customization 17 | ** More Informations 18 | * Build FuguIta from the source repository 19 | ** Getting started 20 | *** About notation 21 | ** Preparing the build environment 22 | *** Setting environment variables 23 | *** OpenBSD full build 24 | *** Installing the commands for build 25 | *** Get the source code of FuguIta 26 | *** Get the source code archives for fiopt 27 | ** Generate a LiveDVD ISO image file 28 | *** Initialize the FuguIta build tool 29 | *** Build fiopt 30 | *** Placement of necessary files 31 | *** Generate the ISO file 32 | ** Creating the LiveUSB disk image file 33 | ** Adjustment 34 | ** Final Processing 35 | *** Generate a blank LiveUSB image 36 | *** Cleaning up the build environment 37 | ** Batch generation of LiveDVDs and LiveUSBs 38 | 39 | *What is FuguIta? 40 | 41 | FuguIta is a live system based on OpenBSD operating system. 42 | 43 | The primary goal of this project is to make OpenBSD, a superior operating 44 | system, easily accessible to everyone. 45 | 46 | In addition, we have implemented a variety of unique features that take 47 | advantage of the characteristics of a live system. 48 | 49 | **Features 50 | 51 | ***Easy to use 52 | 53 | - Bootable from DVD or USB memory stick, no need to install to PC's internal 54 | storage. 55 | 56 | - Operates almost like a normally installed OpenBSD, and the built-in online 57 | manual can be used as it is. 58 | 59 | - Additional software can be installed using OpenBSD's package management 60 | system. 61 | 62 | ***Tracking patches of OpenBSD 63 | 64 | - We publish new release of FuguIta as soon as the OpenBSD development group 65 | announces new errata (security fixes and reliability enhancements). 66 | 67 | - FuguIta itself is also modified and added functions as needed. 68 | 69 | ***Flexible Operation 70 | 71 | - Three boot modes can be selected according to the performance of the 72 | hardware. 73 | 74 | + Mode 0: FuguIta's standard boot mode 75 | 76 | + Mode 1: Short boot time and memory-saving operation 77 | 78 | + Mode 2: Transfers the entire system to memory for faster operation 79 | 80 | + Mode 3: Boot by loading a previously saved files or directories 81 | 82 | + etc ... 83 | 84 | - Multiple FuguIta devices can be attached to accommodate irregular hardware 85 | configurations. 86 | 87 | ***Utilize LiveUSB features 88 | 89 | - Save files and load them at the subsequence boot (can be automated). 90 | 91 | - Update tool for easy and safe updating. 92 | 93 | ***Support tools provided 94 | 95 | - Interactive tools are included for network setup and desktop 96 | environment setup. 97 | 98 | ***Remastering and Customization 99 | 100 | - Remastering LiveDVD and LiveUSB on running FuguIta. 101 | 102 | + LiveDVD to LiveUSB and LiveUSB to LiveDVD remastering are also 103 | possible. 104 | 105 | - Customization is also possible by modifying the contents during the 106 | duplication process. 107 | 108 | - LiveUSB duplication can also encrypt the partition for data storage. 109 | 110 | **More Information 111 | 112 | The official site of FuguIta is https://fuguita.org . 113 | 114 | - Getting Started with FuguIta - A guide to setting up and 115 | fundamental usage of FuguIta. 116 | https://fuguita.org/?FuguIta/StartGuide 117 | 118 | - FuguIta Guide 119 | A comprehensive document of FuguIta - setting up, fundamental and 120 | advanced usage, development. 121 | https://fuguita.org/?FuguItaGuide 122 | 123 | *Build FuguIta from the source repository 124 | 125 | **Getting Started 126 | 127 | The build system for the OpenBSD-based Live System "FuguIta" is 128 | available on GitHub as a copy from the original CVS repository. 129 | 130 | This document explains how to obtain the FuguIta build tool from the 131 | GitHub repository and use it to build FuguIta. 132 | 133 | The steps to build FuguIta are roughly as follows: 134 | 135 | 1. Prepare the working environment, including a full build of OpenBSD 136 | 137 | 2. Generate ISO image file for FuguIta LiveDVD 138 | 139 | 3. Boot the created ISO image file and create a LiveUSB disk image 140 | file on it. 141 | 142 | 4. Create a blank file for creating a LiveUSB from the created 143 | LiveUSB disk image file. 144 | 145 | 5. After making the final adjustments, generate the final version of 146 | the LiveDVD ISO image file and LiveUSB disk image file. 147 | 148 | ***About Notation 149 | 150 | In this document, the following notation is used: 151 | 152 | 153 | Location of working directory (e.g. /home/kaw/local) 154 | 155 | Directory where the build work will be performed (directory of the 156 | build tool obtained from GitHub = /FuguIta-master) 157 | 158 | Location of the OpenBSD installation set 159 | (e.g. /opt/build/dist/amd64) 160 | 161 | OpenBSD release (e.g. 7.6) 162 | 163 | REL without the dot (e.g. 76) 164 | 165 | The target platform (e.g. amd64) 166 | 167 | When running a build, replace these notations with the actual values. 168 | 169 | **Preparing the build environment 170 | 171 | From now on, everything from preparing the build environment to 172 | completing the build process will be done with root privileges. 173 | 174 | ***Setting environment variables 175 | 176 | Set the following environment variables as necessary. These 177 | environment variables are optional, so the build system will work even 178 | if you do not set them. If you set them, you can take advantage of the 179 | performance of multi-core CPUs to reduce processing time. 180 | 181 | export KERNOPT=-j4 # Number of parallel executions when building the kernel 182 | export COMPRESS=pigz # Multi-core compatible gzip alternative 183 | 184 | ***OpenBSD full build 185 | 186 | To build FuguIta, you need the OpenBSD source code, an installation 187 | set created from the source code, and a ports tree. Follow the 188 | instructions in the OpenBSD release(8) manual page 189 | https://man.openbsd.org/release.8 190 | to do the following: 191 | 192 | - Obtaining and updating the OpenBSD source code 193 | - OpenBSD full build 194 | - Generate an installation set 195 | - Obtaining and updating the ports tree 196 | 197 | ***Installing commands for build 198 | 199 | Install third-party commands required to build FuguIta from packages 200 | to the build environment. 201 | 202 | pkg_add gmake rsync pv 203 | pkg_add pigz # (If you set the COMPRESS environment variable) 204 | 205 | ***Get the source code for FuguIta 206 | 207 | Get the FuguIta build system from GitHub 208 | 209 | mkdir -p # If does not exist, create it. 210 | 211 | cd 212 | ftp https://github.com/ykaw/FuguIta/archive/refs/heads/master.tar.gz 213 | tar xvzf master.tar.gz # The FuguIta-master directory will be created. 214 | cd 215 | 216 | ***Get the source code archives for fiopt 217 | 218 | fiopt (FuguIta Optional) is third-party software required to run 219 | FuguIta. 220 | In the current release, there are three: rsync, rlwrap, and pv. These 221 | are built separately from ports and installed under /usr/fuguita/bin. 222 | Obtain the source code for these using the OpenBSD ports system as 223 | follows. The source code is placed in /usr/ports/distfiles. 224 | 225 | cd /usr/ports 226 | for tgz in rsync xxhash rlwrap pv; do (cd */$tgz && make fetch); done 227 | 228 | xxhash is a fast hashing library used when building rsync. 229 | 230 | ***Creating a LiveDVD ISO image file 231 | 232 | Initialize the FuguIta build tool 233 | 234 | Create the directories required for the build. 235 | 236 | cd 237 | make init 238 | 239 | ***Build fiopt 240 | 241 | Compile and install each piece of fiopt software. The installed 242 | software will be compiled into an archive named fiopt.tgz. 243 | 244 | cd /lib/fiopt 245 | ln -s /usr/ports/distfiles/*.tar.gz . 246 | make RSYNC=rsync-3.4.1 XXHASH=xxHash-0.8.2 RLWRAP=rlwrap-0.46.1 PV=pv-1.8.5 247 | 248 | The version of each software should match what was actually acquired. 249 | 250 | ***Placement of necessary files 251 | 252 | Place OpenBSD release sets and third-party software in the 253 | install_sets directory. 254 | 255 | cd /install_sets 256 | ln -s /*.tgz . 257 | ln -s /lib/fiopt/fiopt.tgz . 258 | 259 | In this example, a symbolic link is used, but copying is also possible. 260 | 261 | ***Generate the ISO file 262 | 263 | Generate the LiveDVD release file 264 | 265 | cd 266 | make setup # Set up the bootloader, RAMdisk root, and fuguita--.ffsimg 267 | make livedvd # Set up the OS file tree and write it to an image file 268 | 269 | 270 | **Creating the LiveUSB disk image file 271 | 272 | This build system does not have the ability to create a LiveUSB 273 | release image from scratch, so boot the LiveDVD ISO image you just 274 | generated. 275 | 276 | - On the launched FuguIta, use the newdrive function of the usbfadm 277 | utility to create a LiveUSB release image . 278 | - Create a fast boot cache 279 | 280 | cd /etc/fuguita 281 | gen_mode0sldir 282 | ls -l # Verify that the mode0symlinks.cpio.gz file has been created 283 | 284 | Copy the LiveUSB image and fast boot cache you created to the original 285 | build environment. 286 | 287 | mount /dev/sdXn /mnt 288 | cp FuguIta---yyyymmddn.img /mnt/ 289 | cp /etc/fuguita/mode0symlinks.cpio.gz /mnt//lib/mode0symlinks.cpio.gz. 290 | umount /mnt 291 | 292 | Stop the environment in which the LiveUSB release image was created 293 | and return to the original build environment. 294 | 295 | **Adjustment 296 | 297 | The file /lib/global.conf. defines the system constants 298 | for FuguIta, but you should rewrite these to the optimal values 299 | ​​obtained by actually building the package. 300 | 301 | expr $(wc -c < livecd.iso) / 1024 / 1024 + 10 302 | 1149 # Size of LiveUSB a partition 303 | vi lib/global.conf. 304 | 305 | fuguita_sys_mb=1149 # size of sysmedia.img <-- Set the value calculated earlier here 306 | newdrive_defswap=16M # default swap size at usbfadm newdrive 307 | memfstype=mfs # 'mfs' or 'tmpfs' 308 | mfs_max_mb=30720 # mfs hard limit - 30GB 309 | 310 | **Final Processing 311 | 312 | ***Generate a blank LiveUSB image 313 | 314 | A LiveUSB blank image is a raw LiveUSB disk image that has been erased 315 | with everything except the partition configuration, boot loader, and 316 | livecd-config///noasks in the d partition. 317 | Using a blank LiveUSB image allows you to generate a LiveUSB image 318 | directly from the build system, without having to boot a LiveCD and 319 | then use usbfadm newdrive to create a LiveUSB image. 320 | 321 | Follow the steps below to create a blank LiveUSB image: 322 | 323 | make blank-img 324 | make blank-img-clean 325 | 326 | After this step, a file called sysmedia--.img.gz will be 327 | generated, which is the compressed blank LiveUSB image. 328 | 329 | ***Cleaning up the build environment 330 | 331 | The following steps will initialize the build system, leaving only the 332 | blank LiveUSB image. 333 | 334 | rm -rf sysmedia/* 335 | rm -f FuguIta---*.iso FuguIta---*.img 336 | make distclean 337 | 338 | **Batch creation of LiveDVDs and LiveUSBs 339 | 340 | Generate the official distribution from the initialized build system. 341 | Execute "make all" to generate the FuguIta LiveDVD ISO image and 342 | LiveUSB disk image in one go. 343 | 344 | make init 345 | cd /install_sets 346 | ln -s /lib/fiopt/fiopt.tgz . 347 | ln -s /*.tgz . 348 | cd 349 | make setup && make all 350 | 351 | Finally, FuguIta---yymmddn.iso.gz and 352 | FuguIta---yymmddn.iso.gz will be generated. 353 | -------------------------------------------------------------------------------- /lib/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | bootbin 3 | mode0symlinks.cpio.gz.* 4 | -------------------------------------------------------------------------------- /lib/010_extract.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | # Copyright (c) 2022--2025, Yoshihiro Kawamata 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in 15 | # the documentation and/or other materials provided with the 16 | # distribution. 17 | # 18 | # * Neither the name of the Yoshihiro Kawamata nor the names of its 19 | # contributors may be used to endorse or promote products derived 20 | # from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | #======================================== 35 | # 36 | # 010_extract.sh - Extract OpenBSD's install set to staging directory 37 | # KAWAMATA, Yoshihiro / kaw@on.rim.or.jp 38 | # 39 | # $Id: 010_extract.sh,v 1.13 2025/01/01 00:58:54 kaw Exp $ 40 | # 41 | #======================================== 42 | 43 | set -e 44 | #set -x 45 | 46 | ver=$(uname -r) 47 | shortver=$(echo $ver|tr -dc 0-9) 48 | 49 | if [ -d staging ]; then 50 | rnd=${RANDOM}_${RANDOM} 51 | mv staging staging.$rnd 52 | rm -rf staging.$rnd & 53 | fi 54 | 55 | mkdir staging 56 | cd staging 57 | pv -N "base${shortver}" ../install_sets/base${shortver}.tgz | tar xzpf - 58 | pv -N "comp${shortver}" ../install_sets/comp${shortver}.tgz | tar xzpf - 59 | pv -N "game${shortver}" ../install_sets/game${shortver}.tgz | tar xzpf - 60 | pv -N "man${shortver}" ../install_sets/man${shortver}.tgz | tar xzpf - 61 | pv -N "xbase${shortver}" ../install_sets/xbase${shortver}.tgz | tar xzpf - 62 | pv -N "xfont${shortver}" ../install_sets/xfont${shortver}.tgz | tar xzpf - 63 | pv -N "xserv${shortver}" ../install_sets/xserv${shortver}.tgz | tar xzpf - 64 | pv -N "xshare${shortver}" ../install_sets/xshare${shortver}.tgz | tar xzpf - 65 | pv -N "etc${shortver}" ./var/sysmerge/etc.tgz | tar xzpf - 66 | pv -N "xetc${shortver}" ./var/sysmerge/xetc.tgz | tar xzpf - 67 | if [[ -f ../install_sets/fiopt${shortver}.tgz ]]; then 68 | pv -N "fiopt${shortver}" ../install_sets/fiopt${shortver}.tgz | tar xzpf - 69 | fi 70 | 71 | # install packages needed for FuguIta 72 | # 73 | if ls -1 ../install_pkgs/*-*.tgz >/dev/null 2>&1; then 74 | cp ../install_pkgs/*-*.tgz ./tmp/. 75 | fi 76 | 77 | (cd dev && sh ./MAKEDEV std) 78 | 79 | cd .. # back to top of build tools 80 | 81 | # 82 | # perform pkg_add in chrooted environment 83 | # 84 | cat </dev/null 2>&1; then 89 | pkg_add -D unsigned /tmp/*-*.tgz 90 | fi 91 | rm -f /tmp/* 92 | EOT 93 | 94 | cd staging 95 | 96 | # add user's customization, if any 97 | # 98 | if [[ -f ../install_sets/site${shortver}.tgz ]]; then 99 | pv -N "site${shortver}" ../install_sets/site${shortver}.tgz | tar xzpf - 100 | if [[ -f install.site ]]; then 101 | cat install.site >> etc/rc.firsttime 102 | rm install.site 103 | fi 104 | fi 105 | 106 | cd .. # back to top of build tools 107 | 108 | # apply all issued patches except in kernel 109 | # 110 | if [[ -d ./install_patches && -n "$(ls -A ./install_patches)" ]]; then 111 | for patch in ./install_patches/binupdate-$(uname -r)-$(uname -m)-*.tgz; do 112 | tar -C ./staging -xvzpf $patch 113 | done 114 | fi 115 | -------------------------------------------------------------------------------- /lib/020_modify_tree.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | # Copyright (c) 2022--2025, Yoshihiro Kawamata 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in 15 | # the documentation and/or other materials provided with the 16 | # distribution. 17 | # 18 | # * Neither the name of the Yoshihiro Kawamata nor the names of its 19 | # contributors may be used to endorse or promote products derived 20 | # from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | #======================================== 35 | # 36 | # 020_extract.sh - modify OpenBSD's file tree for FuguIta 37 | # KAWAMATA, Yoshihiro / kaw@on.rim.or.jp 38 | # 39 | # $Id: 020_modify_tree.sh,v 1.17 2025/03/24 03:29:58 kaw Exp $ 40 | # 41 | #======================================== 42 | 43 | set -e 44 | set -x 45 | 46 | # remove KARL files ... not needed for R/O filesystem 47 | # 48 | rm -f ./staging/usr/share/relink/kernel.tgz 49 | rm -rf ./staging/usr/share/relink/kernel 50 | 51 | # disable inappropriate commands 52 | # 53 | mv ./staging/usr/sbin/sysupgrade{,.orig} 54 | mv ./staging/usr/sbin/syspatch{,.orig} 55 | cat < ./staging/usr/sbin/sysupgrade 56 | #!/bin/sh 57 | echo Sorry, \${0##*/} does not work correctly on FuguIta. 58 | EOT 59 | cat < ./staging/usr/sbin/syspatch 60 | #!/bin/sh 61 | echo Sorry, \${0##*/} does not work correctly on FuguIta. 62 | echo Please use fiupdate utility to apply patch. 63 | EOT 64 | chown root:bin ./staging/usr/sbin/{sysupgrade,syspatch} 65 | chmod 0555 ./staging/usr/sbin/{sysupgrade,syspatch} 66 | 67 | # fix dangling symlinks 68 | # 69 | ln -sf /bin/chmod ./staging/usr/bin/chflags 70 | ln -sf /bin/chgrp ./staging/usr/sbin/chgrp 71 | ln -sf /sbin/chown ./staging/usr/sbin/chown 72 | ln -sf /sbin/sysctl ./staging/usr/sbin/sysctl 73 | 74 | # for stable shutdown 75 | # replace /sbin/{reboot,halt} with ones on rdroot 76 | # 77 | mv ./staging/sbin/reboot{,.orig} 78 | mv ./staging/sbin/halt{,.orig} 79 | ln -s /boottmp/reboot ./staging/sbin/reboot 80 | ln -s /boottmp/halt ./staging/sbin/halt 81 | 82 | # setup FuguIta specific files/directories 83 | # 84 | 85 | mkdir -p ./staging/usr/fuguita/bin 86 | ln -sf /boottmp/dtjsetup ./staging/usr/fuguita/bin/dtjsetup 87 | 88 | mkdir -p ./staging/usr/fuguita/sbin 89 | for cmd in chnetconf fdadm fiupdate gen_mode0sldir gennetconfs remaster_dvd usbfadm 90 | do 91 | ln -sf /boottmp/$cmd ./staging/usr/fuguita/sbin 92 | done 93 | 94 | mkdir -p ./staging/usr/fuguita/mdec 95 | if [[ -x ./lib/makebootarc_$(uname -m).sh ]]; then 96 | ./lib/makebootarc_$(uname -m).sh 97 | mv bootstuff.$(uname -m).tar.gz ./staging/usr/fuguita/mdec/. 98 | fi 99 | 100 | # some setups in chrooted environment 101 | # 102 | cat <> bsd-fi.mp is for 3 | echo >> multiprocessor kernel (default). 4 | echo >> Enter 'bsd-fi' for Uniprocessor. 5 | echo 6 | set timeout 10 7 | set image /bsd-fi.mp 8 | -------------------------------------------------------------------------------- /lib/boot.conf.arm64: -------------------------------------------------------------------------------- 1 | set tty fb0 2 | echo 3 | echo >> bsd-fi.mp is for 4 | echo >> multiprocessor kernel (default). 5 | echo >> Enter 'bsd-fi' for Uniprocessor. 6 | echo 7 | set timeout 10 8 | set image /bsd-fi.mp 9 | -------------------------------------------------------------------------------- /lib/boot.conf.i386: -------------------------------------------------------------------------------- 1 | echo 2 | echo >> bsd-fi.mp is for 3 | echo >> multiprocessor kernel (default). 4 | echo >> Enter 'bsd-fi' for Uniprocessor. 5 | echo 6 | set timeout 10 7 | set image /bsd-fi.mp 8 | -------------------------------------------------------------------------------- /lib/bootbin/Makefile: -------------------------------------------------------------------------------- 1 | bootbin: bootbin.mk bootbin.cache bootbin.c 2 | ${MAKE} ${MFLAGS} -f bootbin.mk all 3 | 4 | bootbin.mk bootbin.cache bootbin.c: bootbin.conf 5 | crunchgen -E -c bootbin.c -e bootbin -m bootbin.mk bootbin.conf 6 | 7 | bootbin.conf: 8 | .if $(MACHINE) == "amd64" 9 | cat ../bootbin.conf.orig.amd64 > bootbin.conf 10 | .else 11 | cat ../bootbin.conf.orig > bootbin.conf 12 | .endif 13 | 14 | .include 15 | -------------------------------------------------------------------------------- /lib/bootbin/bootbin.conf.orig: -------------------------------------------------------------------------------- 1 | srcdirs ../special 2 | srcdirs /usr/src/distrib/special 3 | 4 | progs init gzip ln disklabel mount mount_ffs mount_cd9660 mount_msdos mount_ntfs mount_ext2fs mount_vnd vnconfig umount newfs sed sleep sysctl swapctl reboot 5 | 6 | ln swapctl swapon 7 | ln reboot halt 8 | ln newfs mount_mfs 9 | 10 | libs -lutil 11 | -------------------------------------------------------------------------------- /lib/bootbin/bootbin.conf.orig.amd64: -------------------------------------------------------------------------------- 1 | srcdirs ../special 2 | srcdirs /usr/src/distrib/special 3 | 4 | progs init gzip ln disklabel mount mount_ffs mount_cd9660 mount_msdos mount_ntfs mount_ext2fs mount_vnd vnconfig umount newfs sed sleep sysctl swapctl reboot 5 | 6 | ln swapctl swapon 7 | ln reboot halt 8 | ln newfs mount_mfs 9 | 10 | libs -z nobtcfi -lutil 11 | -------------------------------------------------------------------------------- /lib/bootbin/special/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.39 2015/04/13 21:27:07 deraadt Exp $ 2 | 3 | SUBDIR=init mount_ntfs mount_vnd newfs swapctl sysctl vnconfig 4 | 5 | .include 6 | -------------------------------------------------------------------------------- /lib/bootbin/special/init/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/init/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.3 2009/10/28 07:36:49 deraadt Exp $ 2 | 3 | PROG= init 4 | DPADD= ${LIBUTIL} 5 | LDADD= -lutil 6 | .PATH: /usr/src/sbin/init 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /lib/bootbin/special/mount_ntfs/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/mount_ntfs/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.7 2007/12/09 19:48:55 martin Exp $ 2 | 3 | .if (${MACHINE} == "alpha" || ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "arm64") 4 | PROG= mount_ntfs 5 | SRCS= mount_ntfs.c getmntopts.c 6 | .else 7 | NOPROG= 8 | .endif 9 | 10 | MOUNT= /usr/src/sbin/mount 11 | CFLAGS+= -I${MOUNT} 12 | .PATH: ${MOUNT} /usr/src/sbin/mount_ntfs 13 | 14 | .include 15 | -------------------------------------------------------------------------------- /lib/bootbin/special/mount_vnd/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/mount_vnd/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.11 2019/04/25 22:11:35 deraadt Exp $ 2 | 3 | PROG= mount_vnd 4 | LDADD= -lutil 5 | DPADD= ${LIBUTIL} 6 | 7 | CDIAGFLAGS+= -Wall 8 | 9 | .PATH: /usr/src/sbin/mount_vnd 10 | 11 | .include 12 | -------------------------------------------------------------------------------- /lib/bootbin/special/newfs/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/newfs/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.8 2016/03/30 06:38:43 jmc Exp $ 2 | 3 | PROG= newfs 4 | SRCS= dkcksum.c getmntopts.c newfs.c mkfs.c 5 | 6 | MOUNT= /usr/src/sbin/mount 7 | CFLAGS+=-DMFS -I${MOUNT} 8 | .PATH: ${MOUNT} /usr/src/sbin/disklabel /usr/src/sbin/newfs 9 | 10 | DPADD= ${LIBUTIL} 11 | LDADD= -lutil 12 | 13 | #LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs 14 | 15 | .include 16 | -------------------------------------------------------------------------------- /lib/bootbin/special/swapctl/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/swapctl/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.4 2016/03/30 06:38:43 jmc Exp $ 2 | # $NetBSD: Makefile,v 1.2 1997/06/12 16:18:50 mrg Exp $ 3 | 4 | PROG= swapctl 5 | SRCS= swapctl.c swaplist.c 6 | LDADD= -lutil 7 | DPADD= ${LIBUTIL} 8 | 9 | .PATH: /usr/src/sbin/swapctl 10 | 11 | LINKS= ${BINDIR}/swapctl ${BINDIR}/swapon 12 | 13 | .include 14 | -------------------------------------------------------------------------------- /lib/bootbin/special/sysctl/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/sysctl/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.14 2019/07/03 10:32:57 dlg Exp $ 2 | 3 | PROG= sysctl 4 | MAN= sysctl.8 5 | 6 | CPPFLAGS+= -D_LIBKVM 7 | 8 | .PATH: /usr/src/sbin/sysctl 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /lib/bootbin/special/vnconfig/.cvsignore: -------------------------------------------------------------------------------- 1 | .cvsignore 2 | obj 3 | -------------------------------------------------------------------------------- /lib/bootbin/special/vnconfig/Makefile: -------------------------------------------------------------------------------- 1 | # $OpenBSD: Makefile,v 1.1 2019/04/25 16:50:36 deraadt Exp $ 2 | 3 | PROG= vnconfig 4 | LDADD= -lutil 5 | DPADD= ${LIBUTIL} 6 | 7 | CDIAGFLAGS+= -Wall 8 | 9 | .PATH: /usr/src/sbin/vnconfig 10 | 11 | .include 12 | -------------------------------------------------------------------------------- /lib/create_imgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #---------------------------------------- 4 | # create_imgs.sh - create sysmedia.img and fuguita-*.ffsimg 5 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 6 | # $Id: create_imgs.sh,v 1.13 2025/01/01 00:58:54 kaw Exp $ 7 | #---------------------------------------- 8 | 9 | # Copyright (c) 2023--2025 10 | # Yoshihiro Kawamata 11 | # 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions are 16 | # met: 17 | # 18 | # * Redistributions of source code must retain the above copyright 19 | # notice, this list of conditions and the following disclaimer. 20 | # 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in 23 | # the documentation and/or other materials provided with the 24 | # distribution. 25 | # 26 | # * Neither the name of Yoshihiro Kawamata nor the names of its 27 | # contributors may be used to endorse or promote products derived 28 | # from this software without specific prior written permission. 29 | # 30 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | set -e 43 | #set -x 44 | 45 | # Strategy: pass1: measure the offset between planned and actual capacity 46 | # pass2: create the target image file using the measured offset 47 | 48 | # measure total size and number of files under staging/ 49 | # 50 | stage_files=$(find staging -print | wc -l) # files under staging 51 | stage_size=$((1+$(du -sk staging | cut -f1))) # staging in KB 52 | stage_capa_enough=$((12*stage_size/10)) # increase capacity 20% for trial 53 | 54 | cat < config.txt 23 | 24 | # bootaa64.efi not found: replace this with a command line to create efi/boot/bootaa64.efi 25 | cp /usr/mdec/BOOTAA64.EFI efi/boot/bootaa64.efi 26 | 27 | # startup.nsh not found: replace this with a command line to create efi/boot/startup.nsh 28 | echo bootaa64.efi > efi/boot/startup.nsh 29 | 30 | # bootaa64.efi not found: replace this with a command line to create efi/openbsd/bootaa64.efi 31 | cp /usr/mdec/BOOTAA64.EFI efi/openbsd/bootaa64.efi 32 | 33 | cp -p /usr/local/share/raspberrypi-firmware/boot/fixup.dat fixup.dat 34 | cp -p /usr/local/share/raspberrypi-firmware/boot/fixup4.dat fixup4.dat 35 | cp -p /usr/local/share/raspberrypi-firmware/boot/overlays/disable-bt.dtbo overlays/disable-bt.dtbo 36 | cp -p /usr/local/share/raspberrypi-firmware/boot/start.elf start.elf 37 | cp -p /usr/local/share/raspberrypi-firmware/boot/start4.elf start4.elf 38 | 39 | # found u-boot.bin in multiple paths 40 | # please select (uncomment) from following lines 41 | # dup: cp -p /usr/local/share/u-boot/mvebu_espressobin-88f3720/u-boot.bin u-boot.bin 42 | # dup: cp -p /usr/local/share/u-boot/mvebu_mcbin-88f8040/u-boot.bin u-boot.bin 43 | # dup: cp -p /usr/local/share/u-boot/qemu_arm64/u-boot.bin u-boot.bin 44 | cp -p /usr/local/share/u-boot/rpi_arm64/u-boot.bin u-boot.bin 45 | 46 | tar cvzf '../bootstuff.arm64.tar.gz' . 47 | cd .. 48 | rm -r 'bootstuff.arm64' 49 | -------------------------------------------------------------------------------- /lib/setup_fsimg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #---------------------------------------- 4 | # setup_fsimg.sh - setup file system image with specified size 5 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 6 | # $Id: setup_fsimg.sh,v 1.13 2025/01/01 00:58:54 kaw Exp $ 7 | #---------------------------------------- 8 | 9 | # Copyright (c) 2021--2025 10 | # Yoshihiro Kawamata 11 | # 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions are 16 | # met: 17 | # 18 | # * Redistributions of source code must retain the above copyright 19 | # notice, this list of conditions and the following disclaimer. 20 | # 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in 23 | # the documentation and/or other materials provided with the 24 | # distribution. 25 | # 26 | # * Neither the name of Yoshihiro Kawamata nor the names of its 27 | # contributors may be used to endorse or promote products derived 28 | # from this software without specific prior written permission. 29 | # 30 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | set -e 43 | #set -x 44 | 45 | errmsg () { 46 | echo "$0: $@" >&2 47 | } 48 | 49 | usage () { 50 | echo "usage: $0 img_file du_in_fs[KMG] [max_files_in_fs] ['fs_options']" >&2 51 | } 52 | 53 | err_exit () { 54 | if [ -n "$1" ]; then 55 | errmsg "$@" 56 | fi 57 | usage 58 | exit 1 59 | } 60 | 61 | # notice for progress 62 | # 63 | banner () { 64 | cat</dev/null); then 80 | err_exit illegal str: "'$valstr'" 81 | fi 82 | 83 | local val=${valstr%%[KMG]} # pick up value part 84 | local fac=${valstr##*[0-9]} # pick up factor part 85 | 86 | # calculate bytes 87 | # 88 | case "$fac" in 89 | "") echo "$val";; 90 | K) echo "$((1024*val))";; 91 | M) echo "$((1024*1024*val))";; 92 | G) echo "$((1024*1024*1024*val))";; 93 | *) err_exit "can't be happen:" val="'$val'" fac="'$fac'" 94 | esac 95 | } 96 | 97 | # main from here 98 | # 99 | if [ -z "$2" ]; then 100 | err_exit "more argument required" 101 | fi 102 | 103 | fsimg="$1" # name of image file 104 | imgsize=$(defactor "$2") # size of image file 105 | maxfiles="$3" # files to be contained 106 | fs_opts="$4" # newfs options 107 | tgt_part='a' # target partition 108 | 109 | # find unused vnode device 110 | vndev=$(vnconfig -l | grep 'not in use' | head -n 1 | cut -d: -f1) 111 | if [ -z "$vndev" ]; then 112 | err_exit "no vnode devices available" 113 | fi 114 | 115 | # create an image file 116 | # Properly utilize buffering to write faster 117 | size_m=$(( imgsize / (1024*1024) )) # image size in MB 118 | size_rem=$(( imgsize % (1024*1024) )) # remainder divided by 1MB 119 | size_k=$(( size_rem / 1024 )) # remainder in KB 120 | 121 | # write to file: note that less than 1KB will be truncated 122 | banner "creating zero-filled file" 123 | (dd if=/dev/zero bs=1m count="$size_m" status=none 124 | dd if=/dev/zero bs=1k count="$size_k" status=none) \ 125 | | pv -N "$fsimg" -s "$((imgsize/1024))"K > "$fsimg" 126 | 127 | vnconfig "$vndev" "$fsimg" 128 | 129 | # setup fdisk and disklabel partition 130 | banner "setup fdisk/disklabel partition" 131 | echo "e 3\nA6\nn\n64\n*\nw\nq" | fdisk -e "$vndev" >/dev/null 132 | fdisk "$vndev" 133 | echo "a ${tgt_part}\n64\n*\n4.2BSD\nw\nq" | disklabel -E "$vndev" >/dev/null 134 | disklabel -pm "$vndev" 135 | 136 | # calculate appropriate inode density 137 | if [ -n "$maxfiles" ]; then 138 | idense="-i $((imgsize/maxfiles))" 139 | fi 140 | 141 | # format file system 142 | banner "formatting partiton" 143 | newfs -O 1 -o space -m 0 $fs_opts $idense "/dev/r${vndev}${tgt_part}" 144 | 145 | # display result 146 | banner "resulted filesystem" 147 | if mount "/dev/${vndev}${tgt_part}" /mnt; then 148 | echo 149 | df -ki | egrep "^(Filesystem|/dev/${vndev}${tgt_part})" 150 | echo 151 | echo "Summary:" 152 | echo " max files: ${maxfiles:-not given}" 153 | idense=${idense#-i } 154 | echo " newfs -i: ${idense:-auto}" 155 | df -k \ 156 | | awk '$1 == "/dev/'${vndev}${tgt_part}'"\ 157 | {printf(" specified: %.1fM\n allocated: %.1fM\n shrinked: %dK\n", 158 | '$((imgsize/1024/1024))', 159 | $2/1024, 160 | '$((imgsize/1024))'-$2)}' 161 | umount /mnt 162 | fi 163 | 164 | # clean ups 165 | vnconfig -u "$vndev" 166 | 167 | banner "done." 168 | -------------------------------------------------------------------------------- /lib/tools/compress_man.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #======================================== 4 | # compress_man.sh - compress and link man pages 5 | # for live system authoring 6 | # 7 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 8 | # $Id: compress_man.sh,v 1.1 2025/03/15 18:58:35 kaw Exp $ 9 | #======================================== 10 | 11 | # Copyright (c) 2010--2025 12 | # Yoshihiro Kawamata 13 | # 14 | # All rights reserved. 15 | # 16 | # Redistribution and use in source and binary forms, with or without 17 | # modification, are permitted provided that the following conditions are 18 | # met: 19 | # 20 | # * Redistributions of source code must retain the above copyright 21 | # notice, this list of conditions and the following disclaimer. 22 | # 23 | # * Redistributions in binary form must reproduce the above copyright 24 | # notice, this list of conditions and the following disclaimer in 25 | # the documentation and/or other materials provided with the 26 | # distribution. 27 | # 28 | # * Neither the name of Yoshihiro Kawamata nor the names of its 29 | # contributors may be used to endorse or promote products derived 30 | # from this software without specific prior written permission. 31 | # 32 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 35 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 37 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 38 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 39 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 40 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 41 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 42 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | find . -type f \( -name '*.[0-9]' -o -name '*.[0-9][a-z]' \) -links 1 -print | xargs gzip -v9 45 | 46 | find . -type f \( -name '*.[0-9]' -o -name '*.[0-9][a-z]' \) -links +1 -print | 47 | while read f 48 | do 49 | if file $f | grep -q 'gzip compressed data' 50 | then 51 | mv $f $f.gz 52 | else 53 | gzip -cv9 $f > $f.gz.tmp 54 | mv $f $f.gz 55 | cat $f.gz.tmp > $f.gz 56 | rm $f.gz.tmp 57 | fi 58 | done 59 | 60 | find . -type l \( -name '*.[0-9]' -o -name '*.[0-9][a-z]' \) -print | 61 | while read f 62 | do 63 | ln -s `stat -f '%Y' $f`.gz $f.gz 64 | rm $f 65 | done 66 | -------------------------------------------------------------------------------- /lib/tools/find1so.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #======================================== 4 | # find1so.sh - generate the command sequence that converts man pages 5 | # man pages beginning with .so directive to files 6 | # hard-linked to the equivalent manpage entry 7 | # 8 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 9 | # $Id: find1so.sh,v 1.1 2025/03/15 18:58:35 kaw Exp $ 10 | #======================================== 11 | 12 | # Copyright (c) 2016--2025 13 | # Yoshihiro Kawamata 14 | # 15 | # All rights reserved. 16 | # 17 | # Redistribution and use in source and binary forms, with or without 18 | # modification, are permitted provided that the following conditions are 19 | # met: 20 | # 21 | # * Redistributions of source code must retain the above copyright 22 | # notice, this list of conditions and the following disclaimer. 23 | # 24 | # * Redistributions in binary form must reproduce the above copyright 25 | # notice, this list of conditions and the following disclaimer in 26 | # the documentation and/or other materials provided with the 27 | # distribution. 28 | # 29 | # * Neither the name of Yoshihiro Kawamata nor the names of its 30 | # contributors may be used to endorse or promote products derived 31 | # from this software without specific prior written permission. 32 | # 33 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 34 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 35 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 36 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 37 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 38 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 39 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 40 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 41 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | 45 | for f in `find * -type f -name '*.[0-9]' -print` 46 | do 47 | if [ `wc -l < $f` -eq 1 ] && grep -q '^\.so ' $f 48 | then 49 | set -- `cat $f` 50 | echo "rm $f && ln -s ${2##*/} $f" 51 | fi 52 | done 53 | -------------------------------------------------------------------------------- /lib/tools/gen_makebootarc_arm64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #======================================== 4 | # gen_makebootarc_arm64 5 | # 6 | # This shell script tries to generate shell command sequence 7 | # to copy apropriate files from RPi FW and u-boot package to 8 | # to specified directory according to the structure of ESP 9 | # (EFI System Partition) 10 | # 11 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 12 | # $Id: gen_makebootarc_arm64.sh,v 1.1 2025/03/15 18:58:35 kaw Exp $ 13 | #======================================== 14 | 15 | # Copyright (c) 2016--2025 16 | # Yoshihiro Kawamata 17 | # 18 | # All rights reserved. 19 | # 20 | # Redistribution and use in source and binary forms, with or without 21 | # modification, are permitted provided that the following conditions are 22 | # met: 23 | # 24 | # * Redistributions of source code must retain the above copyright 25 | # notice, this list of conditions and the following disclaimer. 26 | # 27 | # * Redistributions in binary form must reproduce the above copyright 28 | # notice, this list of conditions and the following disclaimer in 29 | # the documentation and/or other materials provided with the 30 | # distribution. 31 | # 32 | # * Neither the name of Yoshihiro Kawamata nor the names of its 33 | # contributors may be used to endorse or promote products derived 34 | # from this software without specific prior written permission. 35 | # 36 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 37 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 38 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 39 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 40 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 43 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 44 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 45 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 46 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 47 | 48 | # system wide constants 49 | # 50 | readonly ESP=/dev/sd0i 51 | readonly SRC_DIRS='/usr/local/share/raspberrypi-firmware /usr/local/share/u-boot' 52 | 53 | # print error message and exit 54 | # 55 | err_exit () { 56 | echo "${0##*/}: $@" >&2 57 | exit 1 58 | } 59 | 60 | # main: build dir tree and copy files 61 | # 62 | gen_cmds () { 63 | # list of all package files 64 | local src_files="$(find $SRC_DIRS -type f -print | sort)" 65 | 66 | [[ -z "$src_files" ]] && err_exit 'no source files' 67 | 68 | # build two lists 69 | # directories and files in ESP 70 | mount -r $ESP /mnt || err_exit 'cannot mount /mnt readonly' 71 | local cwd=$(pwd) 72 | cd /mnt || err_exit 'cannot cd to /mnt' 73 | local dst_dirs="$(find * -type d -print | sort)" 74 | local dst_files="$(find * -type f -print | sort)" 75 | cd $cwd 76 | umount $ESP 77 | 78 | [[ -z "$dst_dirs" ]] && err_exit 'no destination directories set' 79 | [[ -z "$dst_files" ]] && err_exit 'no destination files set' 80 | 81 | # make directories from the list 82 | # 83 | local path 84 | for path in $dst_dirs; do 85 | echo mkdir -p $path 86 | done 87 | 88 | # generate command sequence for copying files 89 | # 90 | local base 91 | local nfound 92 | for path in $dst_files; do 93 | base=${path##*/} 94 | nfound=$(echo "$src_files" | grep "/$base\$" | wc -l) 95 | if [[ 0 -eq "$nfound" ]]; then 96 | # boot stuff which missing in package directories (/usr/local/*) 97 | # maybe this needs to be created by hand 98 | echo "# $base not found: replace this with a command line to create $path" 99 | elif [[ 1 -eq "$nfound" ]]; then 100 | # found only one, generate copy command 101 | echo cp -p $(echo "$src_files" | grep "/$base\$") $path 102 | elif [[ 2 -le "$nfound" ]]; then 103 | # found multiple 104 | echo "# found $base in multiple paths" 105 | echo "# please select (uncomment) from following lines" 106 | for found in $(echo "$src_files" | grep "/$base\$"); do 107 | echo "# dup: cp -p $found $path" 108 | done 109 | fi 110 | done 111 | } 112 | 113 | ARCNAME="bootstuff.$(uname -m)" 114 | 115 | cat <) { 12 | chomp; 13 | 14 | # strip unnecessary parts 15 | # 16 | s/'.*?'/ /g; # single-quoted strings 17 | s/#.*//; # comments 18 | s/^\s+$//; # only white spaces 19 | next unless $_; # skip blank lines 20 | 21 | printf("%4d:%16s:%s\n", $., $func, $_); 22 | 23 | # function declaration 24 | if (scalar(@w=(/^(${idexp})\s*\(\)\s*{/o)) || 25 | scalar(@w=(/^\s*function\s+(${idexp})\s*{/o))) { 26 | $func=shift @w; 27 | print "FUN: ${func}()\n"; 28 | 29 | # end of function 30 | } elsif (/^}/) { 31 | # end of function 32 | print "END: ${func}()\n"; 33 | $func = 'GLOBAL'; 34 | } else { 35 | 36 | # local variables 37 | if (/^\s*local\s+${idexp}/) { 38 | # local variables 39 | s/;.*//; 40 | s/\$\(.+?\)/ /g; 41 | @names=(/(${idexp})=\S+|(${idexp})/go); 42 | foreach $name (@names) { 43 | if ($name && $name ne 'local') { 44 | print "LOC:$name\n"; 45 | $localvar{$func}{$name}++; 46 | } 47 | } 48 | 49 | # global variables 50 | } elsif (@names=(/(${idexp})=|\${?(${idexp})}?/go)) { 51 | # global variables 52 | foreach $name (@names) { 53 | if ($name && !defined $localvar{$func}{$name}) { 54 | print "GLO:$name\n"; 55 | $var{$name}{$func}++; 56 | } 57 | } 58 | } 59 | } 60 | } 61 | 62 | # listing functions with global variables 63 | # 64 | print "\n"; 65 | print "*global vars:\n"; 66 | $i=1; 67 | foreach $name (sort keys %var) { 68 | print "* $name\n"; 69 | foreach $func (sort keys %{$var{$name}}) { 70 | if (0 <= $localvar{$func}{$name}) { 71 | print "* $func\n"; 72 | } 73 | } 74 | } 75 | 76 | # listing local variables with functions 77 | # 78 | print "\n"; 79 | print "+local vars:\n"; 80 | foreach $func (sort keys %localvar) { 81 | if (%{$localvar{$func}}) { 82 | print "+ $func\n"; 83 | foreach $name (sort keys %{$localvar{$func}}) { 84 | print "+ $name\n"; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/tools/setupfs: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | if [[ $(id -u) -ne 0 ]]; then 4 | echo "${0##*/}: must be a root" >&2 5 | exit 1 6 | fi 7 | 8 | if [[ -z "$2" ]]; then 9 | echo "usage: ${0##*/} imgfile directory [headroom]" >&2 10 | exit 1 11 | fi 12 | 13 | imgfile="$1" 14 | dir="$2" 15 | hdroom="${3:-4m}" 16 | 17 | trap cleanup ERR 18 | 19 | cleanup () { 20 | trap '' ERR 21 | [[ -n "$vn" ]] && vnconfig -u "$vn" 22 | rm -f "$imgfile" 23 | exit 1 24 | } 25 | 26 | set -e 27 | 28 | gap_bl=128 # blocks 29 | gap_b=$((512*gap_bl)) # bytes 30 | 31 | makefs -t ffs \ 32 | -b "$hdroom" \ 33 | -f 10% \ 34 | -o bsize=4096,fsize=512,minfree=0,optimization=space,version=1 \ 35 | -O "$gap_b" \ 36 | "$imgfile" \ 37 | "$dir" 38 | 39 | vn=$(vnconfig "$imgfile") 40 | 41 | fdisk -e "$vn" </dev/null; then 78 | # physical device ... can't destroy 79 | ifconfig $if | grep -q '^ groups: wlan' && ifconfig $if -nwid -nwkey -wpakey 80 | fi 81 | ;; 82 | esac 83 | done >/dev/null 2>&1 84 | } 85 | 86 | printconfig() { 87 | local file=$(stat -f %Y /etc/myname) 88 | file=${file#"${confdir}/"} 89 | file=${file%/myname} 90 | [[ -n "$file" ]] && echo $file 91 | } 92 | 93 | listconfig() { 94 | local path 95 | local defconf=${confdir}/$(printconfig) 96 | local defmark 97 | 98 | for path in $(ls -1d ${confdir}/*); do 99 | defmark=' ' 100 | [[ "$path" = "$defconf" ]] && defmark='*' 101 | if [[ -e "$path/myname" ]]; then 102 | printf "%1s%-10s " "$defmark" ${path#"${confdir}/"} 103 | [[ -r "$path/description" ]] && echo -n $(<$path/description) 104 | echo 105 | fi 106 | done 107 | } 108 | 109 | 110 | #===================== 111 | # main runs from here 112 | #===================== 113 | 114 | PROGNAME="${0##*/}" 115 | 116 | # for fail-safe 117 | # 118 | cd /etc || exit 119 | 120 | # system-wide constants 121 | # 122 | confdir=/etc/fuguita/netconfs 123 | 124 | # parsing command line options 125 | # 126 | cmd=normal 127 | cmds=0 128 | force_config=no 129 | maxargs=1 130 | while getopts dfrplh OPT; do 131 | case "$OPT" in 132 | d) cmd=dont_netstart; cmds=$((cmds+1)) ;; 133 | f) force_config=yes ;; 134 | r) cmd=reset_allnic; cmds=$((cmds+1)) ;; 135 | p) cmd=print_config; cmds=$((cmds+1)) ;; 136 | l) cmd=list_config; cmds=$((cmds+1)) ;; 137 | h) usage; exit;; 138 | *) usage; exit 1;; 139 | esac 140 | case "$OPT" in 141 | d|f) maxargs=1;; 142 | r|p|l) maxargs=0;; 143 | esac 144 | done 145 | shift $((OPTIND-1)) 146 | 147 | # check options/arguments 148 | # 149 | if [[ 1 < $cmds ]]; then 150 | echo "$PROGNAME: -d, -r, -p, or -l is mutually exclusive" 151 | usage 152 | exit 1 153 | elif [[ $force_config = yes && 1 < $# ]]; then 154 | echo "$PROGNAME: requires one argument" 155 | usage 156 | exit 1 157 | elif [[ $maxargs < $# ]]; then 158 | echo "$PROGNAME: too much arguments - $*" 159 | usage 160 | exit 1 161 | fi 162 | 163 | # perform -r, -p or -l 164 | # 165 | case "$cmd" in 166 | 'reset_allinc') resetif; exit;; 167 | 'print_config') printconfig; exit;; 168 | 'list_config') listconfig; exit;; 169 | esac 170 | 171 | # this is "config_name" 172 | # 173 | if [[ -z "$1" ]]; then 174 | newconf=$(printconfig) 175 | else 176 | newconf="$1" 177 | fi 178 | 179 | # extra argument exists 180 | # 181 | if [[ "$newconf" = 'templ.head' || "$newconf" = 'templ.tail' ]]; then 182 | echo "$PROGNAME: You cannot change to '$newconf'" 183 | exit 184 | elif [ ! -f "${confdir}/${newconf}/myname" ]; then 185 | echo "$PROGNAME: no such conf - $newconf" 186 | exit 187 | fi 188 | 189 | # start of reconfiguration 190 | 191 | # remove current files in /etc 192 | # 193 | if [[ -L /etc/myname ]]; then 194 | curconf=$(stat -f %Y /etc/myname) 195 | curconf=${curconf%/*} 196 | if [[ -n "$curconf" ]] && cd "$curconf"; then 197 | for f in *; do 198 | rm -f "/etc/$f" 199 | done 200 | elif [[ ! $cmd = 'force_config' ]]; then 201 | exit 1 202 | fi 203 | fi 204 | 205 | # check sprious hostname.if files 206 | # 207 | set -- /etc/hostname.* 208 | if [[ -e "$1" ]]; then 209 | echo "$PROGNAME: warning: extra hostname.if(s) found: $*" 210 | echo "Remove them manually if not needed." 211 | fi 212 | 213 | 214 | # collect file names to put into /etc 215 | # 216 | putfiles=$(ls -1d $confdir/{templ.{head,tail},$newconf}/* 2>/dev/null | sed -e 's/.*\///' | sort | uniq) 217 | 218 | # link myname and copy other files to /etc 219 | # 220 | cd $confdir/$newconf || exit 1 221 | for f in $putfiles; do 222 | case "$f" in 223 | 'description') 224 | : # do nothing 225 | ;; 226 | 'myname') 227 | ln -sf $confdir/$newconf/myname /etc/myname 228 | ;; 229 | *) 230 | [[ -e "$f" ]] && cp -p "$f" /etc # create a file with the same attribute 231 | : > "/etc/$f" # and make it empty 232 | 233 | # write the setting value with 234 | # concatenating head/tail template (if any) 235 | cat "${confdir}/templ.head/$f" \ 236 | "$f" \ 237 | "${confdir}/templ.tail/$f" >> "/etc/$f" 2>/dev/null 238 | ;; 239 | esac 240 | done 241 | 242 | # perform -d option 243 | # 244 | if [[ $cmd = 'dont_netstart' ]]; then 245 | exit 246 | fi 247 | 248 | # starting network by new configuration 249 | # 250 | resetif 251 | hostname $( " >&2; read line 68 | 69 | if [ X"$line" = X ]; then 70 | echo 1 71 | else 72 | echo -1 73 | fi 74 | } 75 | 76 | #------------------- 77 | # ask user yes or no 78 | # outputs answer to stdout 79 | # 80 | # usage: ask_yn prompt yn 81 | # 82 | # yn ... y: defaults to yes 83 | # n: defaults to no 84 | # r: no default ... ask again 85 | # else: no default ... return -1 if answered not yn 86 | # 87 | # output ... 1: yes, 0: no, -1: else yn, -2: error occured 88 | # 89 | function ask_yn { 90 | 91 | if [ -z "$2" ]; then 92 | echo -2 93 | return 94 | fi 95 | 96 | local prompt="$1"; shift 97 | local yn_default="$1"; shift 98 | local yn_ans 99 | 100 | case X"$yn_default"X in 101 | X[Yy]X) yn_default=Y; prompt="$prompt [Y/n] -> " ;; 102 | X[Nn]X) yn_default=N; prompt="$prompt [y/N] -> " ;; 103 | X[Rr]X) yn_default=R; prompt="$prompt [y/n] -> " ;; 104 | *) yn_default=E; prompt="$prompt [y/n] -> " ;; 105 | esac 106 | 107 | while :; do 108 | echo -n "$prompt" >&2; read yn_ans 109 | 110 | case X"$yn_ans"X in 111 | X[Yy]X) echo 1; return;; 112 | X[Nn]X) echo 0; return;; 113 | XX) 114 | case X"$yn_default"X in 115 | XYX) echo 1; return;; 116 | XNX) echo 0; return;; 117 | XRX) continue;; 118 | *) echo -1; return;; 119 | esac;; 120 | *) 121 | continue;; 122 | esac 123 | done 124 | } 125 | 126 | #------------------- 127 | # ask selection out of multiple items 128 | # outputs answer to stdout 129 | # 130 | # usage: ask_which prompt default item1 item2 ... 131 | # 132 | # Note: although user's choice is one originated 133 | # default is zero originated 134 | # 135 | # output: first word of selected item 136 | # returns empty line unless selected normally 137 | # 138 | function ask_which { 139 | if [ $# -lt 3 ]; then 140 | return 141 | fi 142 | 143 | local prompt="$1"; shift 144 | local default="$1"; shift 145 | local i item val 146 | 147 | # skip null item 148 | # 149 | i=0 150 | for val in "$@"; do 151 | if [ -n "$val" ]; then 152 | item[$i]="$val" 153 | i=$((i+1)) 154 | fi 155 | done 156 | 157 | # only one item is default itself 158 | # 159 | [ "${#item[@]}" = 1 ] && default=${item[0]} 160 | 161 | i=0 162 | while [ -n "${item[$i]}" ]; do 163 | if [ "$default" = "${item[$i]}" ]; then 164 | OIFS="$IFS" 165 | IFS= prompt="$prompt\n"`printf '%3d: [%s]' $((i+1)) ${item[$i]}` 166 | IFS="$OIFS" 167 | else 168 | OIFS="$IFS" 169 | IFS= prompt="$prompt\n"`printf '%3d: %s' $((i+1)) ${item[$i]}` 170 | IFS="$OIFS" 171 | fi 172 | i=$((i+1)) 173 | done 174 | echo "$prompt" >&2 175 | 176 | local ans 177 | ans=`rl_wread '' ''` 178 | 179 | # take first argument 180 | # 181 | set -- $ans 182 | ans=$1 183 | 184 | # return selected item 185 | # 186 | if expr "$ans" : '^[0-9][0-9]*$' >/dev/null && \ 187 | [ "$ans" -le ${#item[@]} ]; then 188 | set -- ${item[$((ans-1))]} 189 | echo $1 190 | elif [ -n "$default" -a -z "$ans" ]; then 191 | set -- $default 192 | echo $1 193 | fi 194 | } 195 | 196 | #------------------- 197 | # read user's input with readline functionality 198 | # outputs echoed to stdout 199 | # 200 | # usage: rl_wread prompt-str default-str [completion words ....] 201 | # 202 | function rl_wread { 203 | local prompt="$1"; shift 204 | local default="$1"; shift 205 | 206 | if which rlwrap >/dev/null 2>&1 ; then 207 | echo "$@" > $RL_WORDS 208 | rlwrap -b '' \ 209 | -f $RL_WORDS \ 210 | -P "$default" \ 211 | sh -f -c 'echo -n "'"$prompt"'->" >&2 ; read w || echo EOF; echo $w' || echo RL_ERR 212 | else 213 | #------------------- 214 | # fallback to dumb input 215 | # 216 | if [ X"$default" = X ]; then 217 | echo -n "${prompt}->" >&2 218 | read w 219 | else 220 | echo -n "$prompt [$default] -> " >&2 221 | read w 222 | if [ X"$w" = X ]; then 223 | w="$default" 224 | fi 225 | fi 226 | echo $w 227 | fi 228 | } 229 | 230 | #------------------- 231 | # echo message to stderr with header string 232 | # 233 | function msg { 234 | echo '***' "$@" 1>&2 235 | } 236 | 237 | #------------------- 238 | # check if this account administrative 239 | # if so, command with root privileges 240 | # will be defined as function '_rootcmd'. 241 | # 242 | function check_rootcmd { 243 | # check type of rootcmd 244 | if [ "$(type _rootcmd)" = "_rootcmd is a function" ]; then 245 | # _rootcmd already defined 246 | return # ok 247 | elif [ "$(type _rootcmd)" != "_rootcmd not found" ]; then 248 | # _rootcmd defined other than a function 249 | msg "The name _rootcmd conflicts with something other than a function." 250 | msg "will exit with error, sorry." 251 | exit 1 252 | fi 253 | 254 | local TAB=$(echo -n "\t") # to make tab visible in a source 255 | local root 256 | local wheel 257 | echo 258 | msg Checking your root authorization... 259 | if id -p | grep -q "^uid${TAB}root$"; then 260 | root=YES 261 | function _rootcmd { 262 | sh -c "$*" 263 | } 264 | elif id -p | egrep -q "^groups${TAB}(.*[0-9A-Za-z_] )?wheel( |\$)"; then 265 | wheel=YES 266 | if grep -q 'permit..*:wheel' /etc/doas.conf 2>/dev/null; then 267 | function _rootcmd { 268 | doas sh -c "$*" 269 | } 270 | else 271 | function _rootcmd { 272 | echo -n 'Root ' # to display "Root Password:" 273 | su root -c "$*" 274 | } 275 | fi 276 | else 277 | msg "You aren't authorized to be root." 278 | msg 'To install packages, you should be root or a member of wheel group.' 279 | exit 1 280 | fi 281 | 282 | if [ "$root$wheel" = "" ]; then 283 | echo 284 | msg "It seems you don't seem to be able to get root privileges." 285 | msg 'To install packages, you should be root or a member of wheel group.' 286 | exit 1 287 | fi 288 | 289 | msg OK. 290 | } 291 | 292 | #======================= 293 | # Active code from here 294 | #======================= 295 | 296 | #------------------- 297 | # initializations 298 | # 299 | 300 | export LANG=C # for rlwrap at unconfigured locale 301 | 302 | trap 'echo $0: interrupted. >&2; clear_exit 1' INT 303 | 304 | if [ ! -r /usr/fuguita/version ]; then 305 | msg FuguIta is not running. 306 | if [ $(ask_yn 'Do you want to run this installer anyway?' y) -ne 1 ]; then 307 | exit 1 308 | fi 309 | fi_version='IS_NOT_HERE' 310 | else 311 | fi_version=$(/dev/null 2>&1; then 431 | echo 432 | msg cannot access to "$checkurl" 433 | msg Please check network reachability, or the URL is correct. 434 | exit 1 435 | fi 436 | 437 | msg OK. 438 | 439 | echo 440 | msg Installing packages: $pkgs 441 | if [ 1 != $(ask_yn "Will you continue?" n) ]; then 442 | exit 443 | fi 444 | 445 | _rootcmd pkg_add -I $pkgs 446 | if [ $? -ne 0 ]; then 447 | msg "Installing package(s) failed." 448 | exit 1 449 | fi 450 | fi 451 | 452 | # Detecting existing .xsession 453 | # 454 | xs="$HOME/.xsession" 455 | 456 | if [ -e "$xs" ]; then 457 | xs_bak="${xs}_$(date +%Y%m%d_%H%M%S)" 458 | echo 459 | msg $xs already exists. 460 | msg This will be replaced with a new file. 461 | msg and the old one will be renamed to $xs_bak. 462 | fi 463 | 464 | # make backup of .xsession 465 | # 466 | echo 467 | msg Rewrite .xsession configuration file. 468 | if [ 1 != $(ask_yn "Will you continue?" n) ]; then 469 | exit 470 | fi 471 | 472 | if [ -n "$xs_bak" ]; then 473 | mv $HOME/.xsession "$xs_bak" 474 | fi 475 | 476 | # write .xsession - head part 477 | # 478 | cat < $xs 479 | #!/bin/sh 480 | . \$HOME/.profile 481 | if [ -x /usr/local/bin/dbus-launch -a -z "\${DBUS_SESSION_BUS_ADDRESS}" ]; then 482 | eval \`dbus-launch --sh-syntax --exit-with-x11\` 483 | fi 484 | 485 | # add fontpaths of fonts installed by pkg_add 486 | # 487 | for dir in \$(ls -1d /usr/local/share/fonts/*/fonts.{dir,scale} 2>/dev/null | sed -e 's/[^/]*$//' | uniq); do 488 | xset fp+ \$dir 489 | done 490 | xset fp rehash 491 | EOF 492 | 493 | # write .xsession - Japanese IM part 494 | # 495 | if [ "$ja_env" = YES ]; then 496 | echo >> $xs 497 | echo "# set language locale" >> $xs 498 | echo "export LANG=ja_JP.UTF-8" >> $xs 499 | case "$im" in 500 | uim-gtk) 501 | xmod="uim" 502 | im_mod="uim" 503 | im_daemon="uim-xim & (sleep 30; uim-toolbar-gtk & ) &" 504 | ;; 505 | fcitx-anthy) 506 | xmod="fcitx" 507 | im_mod="fcitx" 508 | im_daemon="fcitx5 &" 509 | ;; 510 | scim-anthy) 511 | xmod="SCIM" 512 | im_mod="xim" 513 | im_daemon="scim -d" 514 | ;; 515 | ibus-anthy) 516 | xmod="ibus" 517 | im_mod="ibus" 518 | im_daemon="ibus-daemon -d -x -r" 519 | ;; 520 | ibus-skk) 521 | xmod="ibus" 522 | im_mod="ibus" 523 | im_daemon="ibus-daemon -d -x" 524 | ;; 525 | *) 526 | xmod="$im" 527 | im_mod="$im" 528 | im_daemon="$im &" 529 | ;; 530 | esac 531 | cat <> $xs 532 | 533 | # $im 534 | # 535 | export XMODIFIERS="@im=$xmod" 536 | export GTK_IM_MODULE="$im_mod" 537 | export QT_IM_MODULE="$im_mod" 538 | eval "$im_daemon" 539 | EOF 540 | fi 541 | 542 | # write .xsession - Invocation of Desktop software 543 | # 544 | cat <> $xs 545 | 546 | # start DT/WM and clients 547 | # 548 | dt="$dt" 549 | wm="$wm" 550 | case "\$wm" in 551 | fluxbox) 552 | wm="startfluxbox" 553 | ;; 554 | esac 555 | case "\$dt" in 556 | no) 557 | xsetroot -solid gray12 558 | xclock -geometry 115x115-0+0 -analog -update 1 -fg white -bg '#000020' -hd gray25 -hl white & 559 | xterm -geometry +0+0 -rv & 560 | \$wm 561 | ;; 562 | rox-filer) 563 | rox -t top -p pin 564 | \$wm 565 | ;; 566 | xfce) startxfce4 ;; 567 | mate) mate-session ;; 568 | lumina) start-lumina-desktop ;; 569 | lxqt) startlxqt ;; 570 | *) 571 | start\$dt 572 | ;; 573 | esac 574 | 575 | # fail safe 576 | # 577 | if [ \$? -ne 0 ]; then 578 | twm 579 | fi 580 | EOF 581 | 582 | # write generated .xsession to /etc/skel 583 | # 584 | echo 585 | if [ $(ask_yn 'Copy this .xsession file to /etc/skel ?' n) -eq 1 ]; then 586 | copytoskel=yes 587 | check_rootcmd 588 | _rootcmd cp $HOME/.xsession /etc/skel/. 589 | else 590 | copytoskel=no 591 | fi 592 | 593 | # Japanese Specific Setups 594 | # 595 | if [ "$ja_env" = YES ]; then 596 | 597 | # set timezone unless already set 598 | # 599 | if ! ls -l /etc/localtime | egrep -q 'zoneinfo/(Japan|Asia/Tokyo)' ; then 600 | echo 601 | msg Japanese environment and related software have been set up. 602 | msg However, the time zone has not yet been set to JST. 603 | if [ $(ask_yn 'Set timezone to JST?' y) = 1 ]; then 604 | check_rootcmd 605 | _rootcmd ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime 606 | fi 607 | fi 608 | 609 | # set localtime offset of kernel clock if wanted 610 | # 611 | echo 612 | msg When you use this machine both running OpenBSD and Windows. 613 | msg You can set the hardware clock to JST instead of UTC. 614 | if [ $(ask_yn 'Set hardware clock to JST?' n) = 1 ]; then 615 | check_rootcmd 616 | _rootcmd echo 'kern.utc_offset=540' '>>' '/etc/fuguita/netconfs/templ.head/sysctl.conf' 617 | _rootcmd chnetconf -d 618 | msg This will take effect on the next boot. 619 | fi 620 | 621 | # Workaround: 622 | # Japanese glyphs are not displayed by IceWm's default. 623 | # Settings suitable for Japanese will be written in personal preferences. 624 | # 625 | if [[ "$wm" = "icewm" && -f /usr/local/share/icewm/preferences ]]; then 626 | mkdir -p $HOME/.icewm 627 | if ! grep -qi 'font.*sans' $HOME/.icewm/preferences 2>/dev/null; then 628 | grep -i dejavu /usr/local/share/icewm/preferences \ 629 | | sed -e 's/^# *//; s/[Dd]eja[Vv]u //' >> $HOME/.icewm/preferences 630 | if [[ "$copytoskel" = "yes" ]]; then 631 | check_rootcmd 632 | _rootcmd 'cd && cp -pR .icewm /etc/skel/' 633 | fi 634 | fi 635 | fi 636 | fi 637 | 638 | 639 | # That's all 640 | # 641 | echo 642 | msg all installation and configuration completed. 643 | msg Check if your $xs is OK, then re-login to X. 644 | 645 | if [ "$fi_version" != 'IS_NOT_HERE' ]; then 646 | echo 647 | msg 'Note: You can save this configuration and addtionally installed softwares' 648 | msg ' by using usbfadm utility.' 649 | msg ' And can reload them at next boot time by selecting boot mode 3.' 650 | fi 651 | 652 | clear_exit 0 653 | -------------------------------------------------------------------------------- /rdroot/boottmp/etc.login.conf.diff: -------------------------------------------------------------------------------- 1 | --- login.conf.orig Mon Apr 1 10:52:50 2024 2 | +++ login.conf Thu Aug 22 07:09:09 2024 3 | @@ -39,7 +39,7 @@ 4 | # class. 5 | # 6 | default:\ 7 | - :path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/local/bin /usr/local/sbin:\ 8 | + :path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/local/bin /usr/local/sbin /usr/fuguita/bin /usr/fuguita/sbin:\ 9 | :umask=022:\ 10 | :datasize-max=1536M:\ 11 | :datasize-cur=1536M:\ 12 | -------------------------------------------------------------------------------- /rdroot/boottmp/etc.rc.diff: -------------------------------------------------------------------------------- 1 | --- /fuguita/etc/rc Thu May 1 20:16:28 2025 2 | +++ /etc/rc Fri May 2 08:28:16 2025 3 | @@ -174,9 +174,17 @@ 4 | # filesystems, otherwise record which ones are mounted read-only. 5 | for _dkdev in $(df /usr/{lib,libexec} $_relink | 6 | sed '1d;s/ .*//' | sort -u); do 7 | - _mp=$(mount -t ffs | grep "^$_dkdev") || return 8 | + if mount -t ffs | grep -q "^$_dkdev"; then 9 | + _mp=$(mount -t ffs | grep "^$_dkdev") 10 | + elif mount | egrep -q "(tmpfs|mfs).*/ram"; then 11 | + _mp=$($mount | egrep "/ram") 12 | + else 13 | + return 14 | + fi 15 | + 16 | if [[ $_mp == *read-only* ]]; then 17 | - _ro_list="$_ro_list ${_mp%% *}" 18 | + echo "fuguita: can't reorder libraries at this boot mode" 19 | + return 20 | fi 21 | done 22 | 23 | @@ -415,8 +423,9 @@ 24 | # Re-mount the root filesystem read/writeable. (root on nfs requires this, 25 | # others aren't hurt.) 26 | mount -uw / 27 | -chmod og-rwx /bsd 28 | -ln -fh /bsd /bsd.booted 29 | +# KARL disabled 30 | +#chmod og-rwx /bsd 31 | +#ln -fh /bsd /bsd.booted 32 | 33 | rm -f /fastboot 34 | 35 | @@ -610,6 +619,7 @@ 36 | echo 'creating runtime link editor directory cache.' 37 | [[ -d /usr/local/lib ]] && shlib_dirs="/usr/local/lib $shlib_dirs" 38 | [[ -d /usr/X11R6/lib ]] && shlib_dirs="/usr/X11R6/lib $shlib_dirs" 39 | + [[ -d /usr/fuguita/lib ]] && shlib_dirs="/usr/fuguita/lib $shlib_dirs" 40 | ldconfig $shlib_dirs 41 | fi 42 | 43 | @@ -655,7 +665,9 @@ 44 | 45 | # Re-link the kernel, placing the objects in a random order. 46 | # Replace current with relinked kernel and inform root about it. 47 | -/usr/libexec/reorder_kernel & 48 | +echo 'fuguita: disabled KARL because of read-only media' 49 | +echo 50 | +#/usr/libexec/reorder_kernel & 51 | 52 | date 53 | exit 0 54 | -------------------------------------------------------------------------------- /rdroot/boottmp/fdadm: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #======================================== 4 | # 5 | # fdadm - Floppy Disk ADMinistration tool 6 | # KAWAMATA, Yoshihiro / kaw@on.rim.or.jp 7 | # 8 | #======================================== 9 | 10 | # Copyright (c) 2006--2025 Yoshihiro Kawamata 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions are 15 | # met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in 22 | # the documentation and/or other materials provided with the 23 | # distribution. 24 | # 25 | # * Neither the name of the Yoshihiro Kawamata nor the names of its 26 | # contributors may be used to endorse or promote products derived 27 | # from this software without specific prior written permission. 28 | # 29 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | 41 | 42 | echo 'Welcome to Floppy Disk maintenance tool.' 43 | echo '' 44 | echo 'Type ? for help.' 45 | 46 | #------------------- 47 | # command loop 48 | # 49 | while :; do 50 | #------------------- 51 | # prompting 52 | # 53 | echo '' 54 | echo -n "Cmd -> "; read cmd 55 | echo '' 56 | 57 | set X $cmd 58 | 59 | #------------------- 60 | # process every command 61 | # 62 | case X"$2" in 63 | #------------------- 64 | # make new FFS file system 65 | # on floppy disk, /dev/fd0c 66 | # 67 | Xmkfs) 68 | fdformat /dev/rfd0c 69 | 70 | echo -n "newfs /dev/rfd0c, OK? [y/n] -> "; read yn 71 | if [ 1 = `expr "$yn" : '[Yy]$'` ]; then 72 | disklabel -w fd0 floppy 73 | newfs /dev/rfd0c 74 | fi 75 | ;; 76 | 77 | #------------------- 78 | # make list of modified files 79 | # 80 | Xmklist) 81 | echo -n "Making list of modified files ..." 82 | (cd /ram 83 | find -x * -type f -cnewer /boottmp/boot_starts -print \ 84 | | awk '{print "cmp -s", $1, "/fuguita/" $1, "|| echo", $1}' \ 85 | | sh 86 | find -x * -type l -cnewer /boottmp/boot_livecd_rc_ends -print) | sort > /tmp/fdfiles 87 | echo " done." 88 | ;; 89 | 90 | #------------------- 91 | # edit list of modified files 92 | # 93 | Xedlist) 94 | ${EDITOR:-vi} /tmp/fdfiles 95 | ;; 96 | 97 | #------------------- 98 | # write back files listed in /tmp/fdfiles 99 | # to floppy disk 100 | # 101 | Xwrite) 102 | echo -n "Write list of files into /mnt/livecd-config.tar.gz , OK? [y/n] -> "; read yn 103 | if [ 1 = `expr "$yn" : '[Yy]$'` ]; then 104 | if mount /dev/fd0c /mnt; then 105 | (cd /ram && tar -cvzp -f /mnt/livecd-config.tar.gz -I /tmp/fdfiles) 106 | cp /boottmp/livecd-retr.sh.inc /mnt 107 | umount /mnt 108 | else 109 | echo "mounting /dev/fd0c failed" 110 | fi 111 | fi 112 | ;; 113 | 114 | #------------------- 115 | # finish all 116 | # 117 | Xquit|Xbye|Xexit) 118 | rm -f /tmp/fdfiles 119 | break; 120 | ;; 121 | 122 | #------------------- 123 | # null command 124 | # ... only RET or EOF 125 | X) 126 | : # do nothing 127 | ;; 128 | 129 | #------------------- 130 | # other strings are invalid 131 | # then for help message 132 | # 133 | *) 134 | echo "Commands are; 135 | mkfs - make FFS on /dev/rfd0c 136 | mklist - make list of modified files 137 | edlist - edit list of modified files 138 | write - write list files to floppy 139 | bye, exit, quit 140 | - end of this utility" 141 | ;; 142 | esac 143 | done 144 | -------------------------------------------------------------------------------- /rdroot/boottmp/fiupdate: -------------------------------------------------------------------------------- 1 | #!/boottmp/sh 2 | 3 | #======================================== 4 | # 5 | # fiupdate - live updater for FuguIta 6 | # KAWAMATA, Yoshihiro / kaw@on.rim.or.jp 7 | # $Id: fiupdate,v 1.29 2025/01/01 00:58:54 kaw Exp $ 8 | # 9 | #======================================== 10 | 11 | # Copyright (c) 2020--2025 12 | # Yoshihiro Kawamata 13 | # 14 | # All rights reserved. 15 | # 16 | # Redistribution and use in source and binary forms, with or without 17 | # modification, are permitted provided that the following conditions are 18 | # met: 19 | # 20 | # * Redistributions of source code must retain the above copyright 21 | # notice, this list of conditions and the following disclaimer. 22 | # 23 | # * Redistributions in binary form must reproduce the above copyright 24 | # notice, this list of conditions and the following disclaimer in 25 | # the documentation and/or other materials provided with the 26 | # distribution. 27 | # 28 | # * Neither the name of Yoshihiro Kawamata nor the names of its 29 | # contributors may be used to endorse or promote products derived 30 | # from this software without specific prior written permission. 31 | # 32 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 35 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 37 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 38 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 39 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 40 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 41 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 42 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | #=================== 45 | # Utility functions 46 | #=================== 47 | 48 | # echo to stderr 49 | # 50 | echo2 () { 51 | echo "$@" >&2 52 | } 53 | 54 | #------------------- 55 | # ask user yes or no 56 | # outputs answer to stdout 57 | # 58 | # usage: ask_yn prompt yn 59 | # 60 | # yn ... y: default is yes 61 | # n: default is yes 62 | # r: no default ... ask again 63 | # else: no default ... return -1 if answered not yn 64 | # 65 | # output ... 1: yes, 0: no, -1: else yn, -2: error occured 66 | # 67 | ask_yn () { 68 | 69 | if [ -z "$2" ]; then 70 | echo -2 71 | return 72 | fi 73 | 74 | local prompt="$1"; shift 75 | local yn_default="$1"; shift 76 | local yn_ans 77 | 78 | case X"$yn_default"X in 79 | X[Yy]X) yn_default=Y; prompt="$prompt [Y/n] -> " ;; 80 | X[Nn]X) yn_default=N; prompt="$prompt [y/N] -> " ;; 81 | X[Rr]X) yn_default=R; prompt="$prompt [y/n] -> " ;; 82 | *) yn_default=E; prompt="$prompt [y/n] -> " ;; 83 | esac 84 | 85 | while :; do 86 | echo2 -n "$prompt"; read yn_ans 87 | 88 | case X"$yn_ans"X in 89 | X[Yy]X) echo 1; return;; 90 | X[Nn]X) echo 0; return;; 91 | XX) 92 | case X"$yn_default"X in 93 | XYX) echo 1; return;; 94 | XNX) echo 0; return;; 95 | XRX) continue;; 96 | *) echo -1; return;; 97 | esac;; 98 | *) 99 | continue;; 100 | esac 101 | done 102 | } 103 | 104 | # display usage 105 | # 106 | usage () { 107 | cat <&2 108 | Usage: ${PROGNAME} yyyymmddn 109 | 110 | You should locate FuguIta-${REL}-${ARCH}-yyyymmddn.iso.gz 111 | and either SHA256 or MD5 at current directory before invoke this. 112 | EOT 113 | } 114 | 115 | # check existing kernels/ffsimg 116 | # 117 | check_kern_ffsimg () { 118 | readonly FFSIMG=/sysmedia/fuguita-${REL}-${ARCH}.ffsimg 119 | readonly BSDFI=/sysmedia/bsd-fi 120 | readonly BSDFI_MP=/sysmedia/bsd-fi.mp 121 | 122 | if [ ! -f $FFSIMG ]; then 123 | echo2 "$FFSIMG not found (other version/arch ?)" 124 | ls -l /sysmedia >&2 125 | exit 1 126 | fi 127 | 128 | if [ ! -f $BSDFI ]; then 129 | echo2 "$BSDFI not found (device for saving data only?)" 130 | ls -l /sysmedia >&2 131 | exit 1 132 | fi 133 | 134 | if [ ! -f $BSDFI_MP ]; then 135 | echo2 "$BSDFI_MP not found (device for saving data only?)" 136 | ls -l /sysmedia >&2 137 | exit 1 138 | fi 139 | } 140 | 141 | # check mount status 142 | # 143 | check_mnttype () { 144 | local mount_out=$(mount) # cache mount's output 145 | local mnttype=unknown 146 | 147 | if echo "$mount_out" | grep -q '^/dev/.* on /sysmedia-iso type '; then 148 | if echo "$mount_out" | grep -q '/sysmedia-iso type ntfs'; then 149 | mnttype=sys-iso-ntfs # NTFS with only R/O, can't update 150 | else 151 | mnttype=sys-iso 152 | fi 153 | elif echo "$mount_out" | grep -q '^/dev/cd.* on /sysmedia type '; then 154 | mnttype=livedvd 155 | elif ! echo "$mount_out" | grep -q '^/dev/.* on /sysmedia type '; then 156 | mnttype=on-memory 157 | else 158 | mnttype=liveusb 159 | fi 160 | 161 | echo $mnttype 162 | } 163 | 164 | # decompress ISO image 165 | # 166 | decompress_iso () { 167 | rm -f ${FI}.iso 168 | echo2 169 | echo2 "decompressing ${FI}.iso.gz..." 170 | if ! pv ${FI}.iso.gz | gzip -d -o ${FI}.iso; then 171 | rm -f ${FI}.iso 172 | exit 1 173 | fi 174 | } 175 | 176 | # setup update environment 177 | # mount *.ISO as a vnode device 178 | # 179 | setup_iso_content () { 180 | # mount vnode device 181 | mkdir ${FI} 182 | vnconfig vnd0 ${FI}.iso 183 | mount -r /dev/vnd0a ${FI} 184 | } 185 | 186 | # copy executables these are needed to overwrite filesystem image 187 | # to TMPFS 188 | # 189 | setup_rampath () { 190 | mkdir -p /ram/fiupdate.bin 191 | cp -p /bin/{cat,echo,mv,rm,rmdir,sync} \ 192 | $(which pv) \ 193 | /ram/fiupdate.bin/. 194 | 195 | PATH=/boottmp:/ram/fiupdate.bin:$PATH 196 | export PATH 197 | } 198 | 199 | # comfirm update to an user 200 | # 201 | confirm_exec () { 202 | cat < $BSDFI 240 | 241 | echo2 "overwriting multiprocessor kernel..." 242 | pv ${FI}/bsd-fi.mp > $BSDFI_MP 243 | 244 | echo2 "overwriting filesystem image..." 245 | pv ${FI}/fuguita-${REL}-${ARCH}.ffsimg > $FFSIMG 246 | } 247 | 248 | # make disk/partition list, then echo to stdout 249 | # 250 | list_diskpart () { 251 | local disk part part_list 252 | for disk in $(sysctl -n hw.disknames|tr , ' '); do 253 | # fd* and cd* are not needed 254 | # especially disklabel for fd* will never return 255 | case "$disk" in 256 | wd*|sd*) 257 | for part in $(disklabel ${disk%:*} 2>/dev/null \ 258 | | sed -e "/^ [ad-p]: /!d; s/^ \\([ad-p]\\):.*/${disk%:*}\1/"); do 259 | part_list="${part_list:+$part_list }$part" 260 | done;; 261 | esac 262 | done 263 | echo $part_list 264 | } 265 | 266 | # find UNMOUNTED FuguIta's system disk/partition 267 | # 268 | find_free_fisys () { 269 | local part fisys 270 | for part in $(list_diskpart); do 271 | case "$part" in 272 | sd*|wd*) 273 | if mount -r /dev/$part /mnt 2> /dev/null; then 274 | if [ -f /mnt/bsd-fi.mp ]; then 275 | fisys="${fisys:+$fisys }$part" 276 | fi 277 | umount /dev/$part 278 | fi 279 | ;; 280 | esac 281 | done 282 | echo $fisys 283 | } 284 | 285 | # check if single FuguIta's boot device attached 286 | # if success appropriate device set to global 287 | # variable BOOTDEV 288 | # 289 | check_boot_fisys () { 290 | set -- $(find_free_fisys) 291 | if [ $# -le 0 ]; then 292 | echo2 "No FuguIta boot device found" 293 | echo2 "Please attach single FuguIta boot device." 294 | exit 1 295 | elif [ $# -eq 1 ]; then 296 | BOOTDEV="$1" 297 | elif [ $# -gt 1 ]; then 298 | cat <&2 299 | checked 300 | 301 | Multiple FuguIta boot devices found: $* 302 | Please attach single FuguIta boot device. 303 | EOT 304 | exit 1 305 | else 306 | echo2 "can't happen in check_boot_fisys()" 307 | exit 1 308 | fi 309 | } 310 | 311 | # rewrite running ISO image, 312 | # kernels used for boot and 313 | # correnponding ffsimg 314 | # 315 | update_sys_iso () { 316 | # update ISO image file 317 | # 318 | echo2 "overwriting /sysmedia-iso/ISO/${FI}.iso ..." 319 | if ! pv ${FI}.iso > /sysmedia-iso/ISO/${FI}.iso; then 320 | rm -f /sysmedia-iso/ISO/${FI}.iso 321 | cleanups 322 | exit 1 323 | fi 324 | 325 | # update kernel and ffsimg at boot device 326 | # 327 | if mount /dev/$BOOTDEV /mnt; then 328 | if [ -f /mnt/bsd-fi ]; then 329 | echo2 "overwriting uniprocessor kernel..." 330 | pv ${FI}/bsd-fi > /mnt/bsd-fi 331 | fi 332 | 333 | if [ -f /mnt/bsd-fi.mp ]; then 334 | echo2 "overwriting multiprocessor kernel..." 335 | pv ${FI}/bsd-fi.mp > /mnt/bsd-fi.mp 336 | fi 337 | 338 | if [ -f /mnt/fuguita-${REL}-${ARCH}.ffsimg ]; then 339 | echo2 "overwriting filesystem image..." 340 | pv ${FI}/fuguita-${REL}-${ARCH}.ffsimg > /mnt/fuguita-${REL}-${ARCH}.ffsimg 341 | fi 342 | 343 | umount /mnt 344 | else 345 | cleanups 346 | exit 1 347 | fi 348 | } 349 | 350 | # rewrite kernels and ffsimg 351 | # used for boot 352 | # 353 | update_boot_dev () { 354 | # update kernel and ffsimg at boot device 355 | # 356 | if mount /dev/$BOOTDEV /mnt; then 357 | if [ -f /mnt/bsd-fi ]; then 358 | echo2 "overwriting uniprocessor kernel - ${BOOTDEV}:/bsd-fi ..." 359 | pv ${FI}/bsd-fi > /mnt/bsd-fi 360 | fi 361 | 362 | if [ -f /mnt/bsd-fi.mp ]; then 363 | echo2 "overwriting multiprocessor kernel - ${BOOTDEV}:/bsd-fi.mp ..." 364 | pv ${FI}/bsd-fi.mp > /mnt/bsd-fi.mp 365 | fi 366 | 367 | if [ -f /mnt/fuguita-${REL}-${ARCH}.ffsimg ]; then 368 | echo2 "overwriting filesystem image - ${BOOTDEV}:/fuguita-${REL}-${ARCH}.ffsimg ..." 369 | pv ${FI}/fuguita-${REL}-${ARCH}.ffsimg > /mnt/fuguita-${REL}-${ARCH}.ffsimg 370 | fi 371 | 372 | umount /mnt 373 | else 374 | cleanups 375 | exit 1 376 | fi 377 | } 378 | 379 | #================================== 380 | # Active Code from HERE. 381 | #================================== 382 | 383 | # systemwide constants 384 | # 385 | readonly PROGNAME=${0##*/} 386 | readonly REL=$(uname -r) 387 | readonly ARCH=$(uname -m) 388 | 389 | # greetings and notices 390 | # 391 | cat </dev/null; then 448 | rmdir ${PROGNAME}_$$ 449 | else 450 | echo2 "You can't create a file at $(pwd) . Please change CWD." 451 | exit 1 452 | fi 453 | ;; 454 | esac 455 | 456 | # console devices 457 | if [ 0 -lt $(expr $(tty) : '/dev/ttyp[0-9]') ]; then 458 | cat <&2 459 | checked 460 | 461 | It seems you are running this script on X Window System, 462 | via network or something like this. 463 | In this situation, during update, corresponding processes 464 | will be killed and then update may fail. 465 | 466 | Running this on direct console device is highly recommended. 467 | 468 | EOT 469 | 470 | if [ 1 -ne $(ask_yn "Continue anyway?" n) ]; then 471 | exit 1 472 | else 473 | # if continue, any daemon will not be stopped 474 | # before system update 475 | keep_daemon=YES 476 | fi 477 | else 478 | keep_daemon=NO 479 | echo2 "ok" 480 | echo2 481 | fi 482 | cat <&2 592 | 593 | We can't update because NTFS is mounted on /sysmedia-iso with read only. 594 | Please locate the ISO file to \\ISO\\${FI}.iso on running Windows OS. 595 | Sorry for inconvenience. 596 | EOT 597 | exit 1 598 | ;; 599 | on-memory) 600 | # define terminate session 601 | # 602 | cleanups () { umount -f ${FI} 603 | rmdir ${FI} 604 | vnconfig -u vnd0 605 | rm ${FI}.iso; } 606 | 607 | echo2 -n " boot device: " 608 | check_boot_fisys 609 | echo2 "/dev/$BOOTDEV - ok" 610 | 611 | decompress_iso 612 | setup_iso_content 613 | confirm_exec 614 | 615 | stop_all_srvs $keep_daemon 616 | update_boot_dev 617 | ;; 618 | *) 619 | echo2 "unknown file layout - $MNTTYPE (internal inconsistency?)" 620 | exit 1 621 | ;; 622 | esac 623 | echo2 624 | echo2 "update completed." 625 | 626 | # not to perform usbfadm -r 627 | # 628 | if [ -f /etc/rc.shutdown ]; then 629 | mv /etc/rc.shutdown /etc/DISABLED.rc.shutdown 630 | fi 631 | 632 | # reboot ... this is it. 633 | # 634 | sync; sync; sync; sleep 5 635 | echo2 "now rebooting..." 636 | /boottmp/reboot 637 | -------------------------------------------------------------------------------- /rdroot/boottmp/gen_mode0sldir: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #======================================== 4 | # gen_mode0sldir - generate fast-boot cache 5 | # 6 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 7 | # $Id: gen_mode0sldir,v 1.8 2025/01/01 00:58:54 kaw Exp $ 8 | #======================================== 9 | 10 | # Copyright (c) 2010--2025 11 | # Yoshihiro Kawamata 12 | # 13 | # All rights reserved. 14 | # 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are 17 | # met: 18 | # 19 | # * Redistributions of source code must retain the above copyright 20 | # notice, this list of conditions and the following disclaimer. 21 | # 22 | # * Redistributions in binary form must reproduce the above copyright 23 | # notice, this list of conditions and the following disclaimer in 24 | # the documentation and/or other materials provided with the 25 | # distribution. 26 | # 27 | # * Neither the name of Yoshihiro Kawamata nor the names of its 28 | # contributors may be used to endorse or promote products derived 29 | # from this software without specific prior written permission. 30 | # 31 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 36 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 37 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 38 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 39 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | 43 | # environmental check 44 | # 45 | cd /ram || exit 1 46 | if [ ! -d /ram/etc/fuguita ]; then 47 | mkdir /ram/etc/fuguita || exit 1 48 | fi 49 | 50 | # replace some ordinary files to symlinks 51 | # 52 | find -x usr -type f -print | \ 53 | while read fn; do 54 | if [[ -f "/fuguita/$fn" ]]; then 55 | ln -sf "/fuguita/$fn" "$fn" 56 | fi 57 | done 58 | 59 | # archive symlinks with cpio 60 | # 61 | find . \( -type l -o -type d -empty \) -print \ 62 | | sort | pax -w -z -x cpio > /ram/etc/fuguita/mode0symlinks.cpio.gz 63 | -------------------------------------------------------------------------------- /rdroot/boottmp/gennetconfs: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #================================================== 4 | # gennetconfs - generate network coniguration files 5 | # 6 | # $Id: gennetconfs,v 1.25 2025/01/01 00:58:54 kaw Exp $ 7 | #================================================== 8 | 9 | # Copyright (c) 2018--2025 10 | # Yoshihiro Kawamata 11 | # 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions are 16 | # met: 17 | # 18 | # * Redistributions of source code must retain the above copyright 19 | # notice, this list of conditions and the following disclaimer. 20 | # 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in 23 | # the documentation and/or other materials provided with the 24 | # distribution. 25 | # 26 | # * Neither the name of Yoshihiro Kawamata nor the names of its 27 | # contributors may be used to endorse or promote products derived 28 | # from this software without specific prior written permission. 29 | # 30 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | # == Global Variables ==================================================== 43 | # basedir directory where configurations reside 44 | # conf name of configuration 45 | # confdir directory where files to be configure reside 46 | # description contents of confdir/description 47 | # etc_myname contents of /etc/myname 48 | # etc_mygate contents of /etc/mygate 49 | # etc_hosts contents of /etc/hosts 50 | # etc_hostname_if contents of /etc/hostname.if 51 | # etc_resolv_conf contents of /etc/resolv.conf 52 | # etc_sysctl_conf contents of /etc/sysctl.conf 53 | # ifconf4_manu 'yes' if IPv4 manually configured 54 | # ifconf6_manu 'yes' if IPv6 manually configured 55 | # ipv enabled IP version such as '6 4' 56 | # eth_nics detected physical network interfaces 57 | # confnic a network interface to configure 58 | # ======================================================================== 59 | 60 | # quiet output 61 | # print message if -v specified 62 | # 63 | quiet () { 64 | if [[ "$quiet" != 'yes' ]]; then 65 | echo "$@" 66 | fi 67 | } 68 | 69 | # display usage 70 | # 71 | usage () { 72 | cat <&2 73 | 74 | $PROGNAME: generate network configuration files 75 | Usage: $PROGNAME [-b] [-q] [-d 'description'] [-h] [config_name] 76 | -b: surpress banner message 77 | -q: surpress additional explains 78 | -d description: brief description of this config 79 | -h: print this help 80 | EOT 81 | } 82 | 83 | # addvar name [arg1 arg2 ...] 84 | # 85 | # add trailing args 'arg1 arg2 ...' 86 | # to variable 'name' followed by EoL 87 | # ~~~~~~~~~~~~~~~ 88 | addvar () { 89 | [[ -z "$1" ]] && return 90 | local _name="$1"; shift; 91 | eval "${_name}=\"\$${_name}\"\"$*\"\"\\n\"" 92 | } 93 | 94 | # setaddr_4 95 | # 96 | # set configurration for IPv4 address and routing 97 | # 98 | setaddr_4 () { 99 | local testif 100 | local addr_mask 101 | local addr mask gw 102 | 103 | echo 104 | echo 'IPv4 - address and routing:' 105 | echo ' Enter "auto" or "IPv4_address[/mask] [default_gateway]"' 106 | quiet ' "auto" is an automatic setting by DHCP.' 107 | quiet ' The "/mask" part can be specified in either format,' 108 | quiet ' such as "/255.255.255.0" or "/24".' 109 | quiet ' If there is no default gateway,' 110 | quiet ' set the second field to "none" or leave it blank.' 111 | 112 | # randomly choose unused virtual ethernet device 113 | # for test address and mask 114 | # 115 | while :; do 116 | testif=vether$(jot -r 1 1000 1999) # choice with random number 117 | ifconfig $testif >/dev/null 2>&1 || break # unused ... choose this 118 | sleep 1 # testif already exists ... retry after 1sec 119 | done 120 | 121 | # read value and test it 122 | # 123 | while :; do 124 | echo -n '[auto] -> '; read addr_mask gw 125 | case "$addr_mask" in 126 | [Aa][Uu][Tt][Oo]*|'') # autoconf 127 | addvar etc_hostname_if 'inet autoconf' 128 | break ;; 129 | *.*.*.*/[1-9]|*.*.*.*/[123][0-9]) 130 | # masklen 131 | set -- $(echo "$addr_mask" | tr / ' ') 132 | addr="$1" 133 | mask="$2" 134 | if ifconfig $testif inet "$addr/$mask" >/dev/null 2>&1; then 135 | addvar etc_hostname_if "inet $addr/$mask" 136 | ifconf4_manu=yes 137 | break 138 | else 139 | echo "bad value - $addr_mask" 140 | fi 141 | ;; 142 | *.*.*.*/*.*.*.*) 143 | # maskaddr 144 | set -- $(echo "$addr_mask" | tr / ' ') 145 | addr="$1" 146 | mask="$2" 147 | if ifconfig $testif inet "$addr" netmask "$mask" >/dev/null 2>&1; then 148 | addvar etc_hostname_if "inet $addr $mask" 149 | ifconf4_manu=yes 150 | break 151 | else 152 | echo "bad value - $addr" 153 | fi 154 | ;; 155 | *.*.*.*) 156 | # no mask specified 157 | if ifconfig $testif inet "$addr_mask" >/dev/null 2>&1; then 158 | set -- $(ifconfig $testif | grep 'inet .* netmask .*') 159 | addr="$2" 160 | mask="$4" 161 | addvar etc_hostname_if "inet $addr $mask" 162 | ifconf4_manu=yes 163 | break 164 | else 165 | echo "bad value - $addr_mask" 166 | fi 167 | ;; 168 | *) 169 | # illegal form 170 | echo "illegal address format - $addr_mask" 171 | ;; 172 | esac 173 | done 174 | 175 | # set addr to hosts 176 | # 177 | [[ -n "$addr" ]] && addvar etc_hosts $addr $(echo -n $etc_myname) # to omit etc_myname's EOL 178 | 179 | # dispose the test device 180 | # 181 | ifconfig $testif destroy >/dev/null 2>&1 182 | 183 | # set default gateway 184 | # 185 | if [[ -n "$gw" && "$gw" = [1-9]*.[1-9]*.[1-9]*.[1-9]* ]]; then 186 | addvar etc_mygate "$gw" 187 | fi 188 | } 189 | 190 | # setaddr_6 191 | # 192 | # set configurration for IPv6 address and routing 193 | # 194 | setaddr_6 () { 195 | local testif 196 | local addr_plen 197 | local addr plen gw 198 | 199 | echo 200 | echo 'IPv6 - address and routing:' 201 | echo ' Enter "auto" or "IPv6_address[/prefixlen] [default_gateway]"' 202 | quiet ' "auto" is an automatic setting by SLAAC.' 203 | quiet ' The "/prefixlen" part can be an integer between 0 and 128.' 204 | quiet ' If there is no default gateway,' 205 | quiet ' set the second field to "none" or leave it blank.' 206 | 207 | # randomly choose unused virtual ethernet device 208 | # for test address and mask 209 | # 210 | while :; do 211 | testif=vether$(jot -r 1 1000 1999) # choice with random number 212 | ifconfig $testif >/dev/null 2>&1 || break 213 | sleep 1 # testif already exists ... retry after 1sec 214 | done 215 | 216 | # read value and test it 217 | # 218 | while :; do 219 | echo -n '[auto] -> '; read addr_plen gw 220 | case "$addr_plen" in 221 | [Aa][Uu][Tt][Oo]*|'') # autoconf 222 | addvar etc_hostname_if 'inet6 autoconf' 223 | break ;; 224 | [:0-9A-Fa-f]*/[0-9]|[:0-9A-Fa-f]*/[1-9][0-9]|[:0-9A-Fa-f]*/1[0-9][0-9]) 225 | # prefixlen 226 | set -- $(echo "$addr_plen" | tr / ' ') 227 | addr="$1" 228 | plen="$2" 229 | if ifconfig $testif inet6 "$addr" prefixlen "$plen" >/dev/null 2>&1; then 230 | addvar etc_hostname_if "inet6 $addr $plen" 231 | ifconf6_manu=yes 232 | break 233 | else 234 | echo "bad value - $addr" 235 | fi 236 | ;; 237 | [:0-9A-Fa-f]*[:0-9A-Fa-f]) 238 | # no prefixlen specified 239 | if ifconfig $testif inet6 "$addr_plen" >/dev/null 2>&1; then 240 | set -- $(ifconfig $testif | grep 'inet6 .* prefixlen .*' | grep -v scopeid) 241 | addr="$2" 242 | plen="$4" 243 | addvar etc_hostname_if "inet6 $addr $plen" 244 | ifconf6_manu=yes 245 | break 246 | else 247 | echo "bad value - $addr_plen" 248 | fi 249 | ;; 250 | *) 251 | # illegal form 252 | echo "illegal address format - $addr_plen" 253 | ;; 254 | esac 255 | done 256 | 257 | # set addr to hosts 258 | # 259 | [[ -n "$addr" ]] && addvar etc_hosts $addr $(echo -n $etc_myname) # to omit etc_myname's EOL 260 | 261 | # dispose the test device 262 | ifconfig $testif destroy >/dev/null 2>&1 263 | 264 | if [[ -n "$gw" && "$gw" = [:0-9A-Fa-f]*[:0-9A-Fa-f] ]]; then 265 | addvar etc_mygate "$gw" 266 | fi 267 | } 268 | 269 | # outif text outfile 270 | # output text to outfile unless text is null 271 | # subfunction for emit_config 272 | # 273 | outif () { 274 | if [[ -n "$1" && -n "$2" ]]; then 275 | quiet " ${confdir}/$2" 276 | echo -n "$1" > $2 277 | fi 278 | } 279 | 280 | # write all setting values to files 281 | # 282 | emit_config () { 283 | quiet '' 284 | quiet 'writing configured values to:' 285 | outif "$description" description 286 | outif "$etc_myname" myname 287 | outif "$etc_mygate" mygate 288 | outif "$etc_hosts" hosts 289 | if [[ -n "$confnic" ]]; then 290 | outif "$etc_hostname_if" hostname.${confnic} 291 | if [[ -e hostname.${confnic} ]]; then 292 | chown root:wheel hostname.${confnic} 293 | chmod 0640 hostname.${confnic} 294 | fi 295 | fi 296 | outif "$etc_resolv_conf" resolv.conf 297 | outif "$etc_sysctl_conf" sysctl.conf 298 | } 299 | 300 | 301 | #===================== 302 | # main runs from here 303 | #===================== 304 | 305 | PROGNAME="${0##*/}" 306 | 307 | # must be root 308 | # 309 | if [ ! `id -un` = root ]; then 310 | echo "$PROGNAME: must be run as a root." 311 | exit 1 312 | fi 313 | 314 | # parsing command line options 315 | # 316 | while getopts bqd:h OPT; do 317 | case "$OPT" in 318 | b) builtin_rc=yes # surpress banner 319 | ;; 320 | q) quiet=yes # no additional messages 321 | ;; 322 | d) addvar description "$OPTARG" 323 | ;; 324 | h) usage; exit;; 325 | *) usage; exit 1;; 326 | esac 327 | done 328 | shift $((OPTIND - 1)) 329 | 330 | # base directory for configurations 331 | # 332 | basedir=/etc/fuguita/netconfs 333 | 334 | # set and cd to configuration directory 335 | # unless specified, run on current working directory 336 | # 337 | if [[ -n "$1" ]]; then 338 | conf="$1" 339 | if [[ "$conf" = 'templ' ]]; then 340 | echo "$PROGNAME: '$conf' is the special name." 341 | echo " You can't configure $conf. Use other name." 342 | exit 1 343 | fi 344 | 345 | confdir="$basedir/$conf" 346 | mkdir -p "$confdir" # even if $confdir already exists 347 | cd "$confdir" || exit 1 348 | else 349 | confdir=$(pwd) 350 | fi 351 | 352 | if [[ "$builtin_rc" != 'yes' ]]; then 353 | cat < '; read ln 366 | addvar description "$ln" 367 | fi 368 | 369 | # Host name 370 | # 371 | echo 372 | echo 'Hostname with domain part (FQDN):' 373 | quiet 'only host name without domain part is also OK.' 374 | while :; do 375 | echo -n '-> '; read ln 376 | if echo "$ln" | grep -q '[^0-9A-Za-z.-]'; then 377 | echo "illgal character in $ln" 378 | continue 379 | elif [[ -z "$ln" ]]; then 380 | continue 381 | else 382 | addvar etc_myname "$ln" 383 | break 384 | fi 385 | done 386 | 387 | # Detect physical network devices 388 | # 389 | for nic in $(ifconfig -a|grep '^[a-z][0-9a-z][0-9a-z]*: '|cut -d: -f1); do 390 | case "$(ifconfig $nic)" in 391 | *'media: Ethernet '*) 392 | eth_nics=${eth_nics:+"$eth_nics "}$nic 393 | ;; 394 | *'media: IEEE802.11 '*) 395 | wifi_nics=${wifi_nics:+"$wifi_nics "}$nic 396 | ;; 397 | esac 398 | done 399 | 400 | # No NICs found ... standalone settings 401 | # 402 | if [[ -z "${eth_nics}${wifi_nics}" ]]; then 403 | echo 404 | echo 'No physical network devices found - setup as standalone...' 405 | addvar etc_resolv_conf 'lookup file' 406 | emit_config 407 | exit 408 | fi 409 | 410 | # IP versions 411 | # 412 | echo 413 | echo 'IP protocol version(s) to be enabled: 4, 6, 46, 64 or "none"' 414 | quiet ' 4: enable only IPv4' 415 | quiet ' 6: enable only IPv6' 416 | quiet ' 46: give priority to IPv4 name resolution' 417 | quiet ' 64: give priority to IPv6 name resolution' 418 | quiet ' none: operate as standalone' 419 | while :; do 420 | echo -n '[64] -> '; read ipver 421 | case "$ipver" in 422 | 46) 423 | ipv='4 6' 424 | addvar etc_resolv_conf 'lookup file bind' 425 | addvar etc_resolv_conf 'family inet4 inet6' 426 | ;; 427 | 64|'') 428 | ipv='6 4' 429 | addvar etc_resolv_conf 'lookup file bind' 430 | addvar etc_resolv_conf 'family inet6 inet4' 431 | ;; 432 | 4) 433 | ipv='4' 434 | addvar etc_resolv_conf 'lookup file bind' 435 | addvar etc_resolv_conf 'family inet4' 436 | ;; 437 | 6) 438 | ipv='6' 439 | addvar etc_resolv_conf 'lookup file bind' 440 | addvar etc_resolv_conf 'family inet6' 441 | ;; 442 | [Nn]*) 443 | echo 'No IP protocols specified - setup as standalone...' 444 | addvar etc_resolv_conf 'lookup file' 445 | emit_config 446 | exit 447 | ;; 448 | *) continue 449 | ;; 450 | esac 451 | break 452 | done 453 | 454 | # List physical network devices 455 | # 456 | echo 457 | echo "Network Interfaces: Choose one" 458 | echo 459 | echo ' NIC type Name' 460 | echo '-------- ----- ------------' 461 | dmesg="$(cat /var/run/dmesg.boot 2>/dev/null; dmesg)" # get device names dmesg 462 | for nic in $eth_nics $wifi_nics; do 463 | if expr "$eth_nics" : ".*$nic" >/dev/null 2>&1 ; then 464 | type=ether 465 | elif expr "$wifi_nics" : ".*$nic" >/dev/null 2>&1 ; then 466 | type=wifi 467 | else 468 | type='???' 469 | fi 470 | prod=$(echo "$dmesg" | sed "/^$nic at .*\".*\"/!d; s/^[^\"]*\"//; s/\".*//" | tail -n 1) 471 | printf "%8s %-5s %s\n" "$nic" "$type" "${prod:-unknown}" 472 | done 473 | 474 | # Spcifying a device 475 | # 476 | set -- $eth_nics $wifi_nics 477 | defnic="$1" # simply, default is the first one found 478 | echo -n "[$defnic] -> "; read nic 479 | confnic=${nic:-$defnic} 480 | 481 | # Non exsitent now 482 | # proceed settings since the device may be created 483 | # in the future (i.e. vether, USB dongle ...) 484 | # 485 | if ! expr "$eth_nics $wifi_nics" : ".*$confnic" >/dev/null; then 486 | echo 487 | echo "Warning: $confnic hasn't been detected yet." 488 | echo " anyway, continue setting..." 489 | fi 490 | 491 | # Wi-Fi settings 492 | # 493 | while :; do # this loop runs once 494 | wlan='' 495 | expr "$wifi_nics" : ".*$confnic" >/dev/null || break # It's not Wi-Fi. 496 | 497 | echo 498 | echo 'Wi-Fi settings:' 499 | echo -n ' SSID -> '; read wifi_ssid 500 | wlan="${wifi_ssid:+nwid $wifi_ssid}" 501 | 502 | echo -n ' WPA Key -> '; read wifi_wpakey 503 | wlan="$wlan${wifi_wpakey:+ wpakey $wifi_wpakey}" 504 | [[ -n "$wifi_wpakey" ]] && break # finish setting here 505 | 506 | echo -n ' WEP Key -> '; read wifi_wepkey 507 | wlan="$wlan${wifi_wepkey:+ nwkey $wifi_wepkey}" 508 | break 509 | done 510 | # 511 | # store the values to var 512 | # 513 | if [[ -n "$wlan" ]]; then 514 | addvar etc_hostname_if "$wlan" 515 | addvar etc_hostname_if "up" 516 | fi 517 | 518 | # IP address and routing 519 | # configure in name resolution order 520 | # 521 | for ipver in $ipv; do 522 | case "$ipver" in 523 | 4) setaddr_4 ;; 524 | 6) setaddr_6 ;; 525 | esac 526 | done 527 | 528 | # DNS settings 529 | # 530 | if [[ "${ifconf4_manu}${ifconf6_manu}" != '' ]]; then 531 | # manual config at least one 532 | echo 533 | echo 'DNS servers: up to 3 IP addresses, separated by spaces' 534 | echo -n '-> '; read dns 535 | set -- $(echo "$dns" | tr -sc '0-9.A-Fa-z:%' ' ') 536 | [[ -n "$1" ]] && addvar etc_resolv_conf "nameserver $1" 537 | [[ -n "$2" ]] && addvar etc_resolv_conf "nameserver $2" 538 | [[ -n "$3" ]] && addvar etc_resolv_conf "nameserver $3" 539 | fi 540 | 541 | # write to configuration files 542 | # 543 | emit_config 544 | 545 | if [[ "$builtin_rc" != 'yes' ]]; then 546 | cat </dev/null 63 | #ln -s fuguita/.??* . 2>/dev/null ; # Maybe not needed 64 | 65 | #------------------------------------------- 66 | # lndir from /ram/usr to /fuguita/usr 67 | # 68 | echo -n "Linking files from /ram to /fuguita ... " 69 | mkdir /ram/usr && cd /ram/usr && lndir -s /fuguita/usr 70 | echo "done" 71 | 72 | #------------------------------------------- 73 | # KLUDGE: Re-lndir under /usr/local/lib/X11/fonts 74 | # 75 | if [ -h /ram/usr/local/lib/X11/fonts ]; then 76 | rm /ram/usr/local/lib/X11/fonts 77 | mkdir -p /ram/usr/local/lib/X11/fonts 78 | (cd /ram/usr/local/lib/X11/fonts && lndir -s /fuguita/usr/local/lib/X11/fonts) 79 | fi 80 | 81 | #------------------------------------------- 82 | # Then, copy again for trivial dirs 83 | # 84 | for d in \ 85 | usr/libexec/auth \ 86 | usr/local/lib/wnn 87 | do 88 | if [ -d /ram/$d ]; then 89 | rm -rf /ram/$d && cd `dirname /fuguita/$d` && pax -rwpe `basename $d` `dirname /ram/$d` 90 | fi 91 | done 92 | 93 | #----------------------- 94 | # Extract an archive 95 | # 96 | echo "Extracting files from floppy to ram ... " 97 | cd /ram 98 | tar xpvzf /mnt/livecd-config.tar.gz 99 | 100 | #----------------------- 101 | # symlink from / to ram 102 | # 103 | cd / 104 | rm -rf /tmp 105 | mv /etc /bootetc 106 | ln -sf ram/* . 107 | cp /boottmp/fstab /etc 108 | 109 | #------------------------------------------- 110 | # symlink rest of contents from / to CD-ROM 111 | # 112 | ln -s fuguita/* . 2>/dev/null 113 | #ln -s fuguita/.??* . 2>/dev/null ; # Maybe not needed 114 | 115 | #------------------------------------------- 116 | # set time stamp of dirs containing font files 117 | # (to avoid re-build font caches) 118 | # 119 | (cd /ram && for d in usr/*/lib/X11/fonts/*; do touch -cm -r /fuguita/$d $d; done) 120 | -------------------------------------------------------------------------------- /rdroot/boottmp/mtree_special.mode0.diff: -------------------------------------------------------------------------------- 1 | --- special.orig Thu May 1 20:16:34 2025 2 | +++ special Fri May 2 08:27:58 2025 3 | @@ -12,6 +12,9 @@ 4 | mem type=char mode=0640 uname=root gname=kmem 5 | .. #dev 6 | 7 | +sbin type=link 8 | +ram type=dir mode=0755 uname=root gname=wheel 9 | + 10 | etc type=dir mode=0755 uname=root gname=wheel 11 | acme-client.conf type=file mode=0644 uname=root gname=wheel optional 12 | bgpd.conf type=file mode=0600 uname=root gname=wheel optional 13 | @@ -128,9 +131,6 @@ 14 | authorized_keys type=file mode=0600 uname=root gname=wheel 15 | .. #root/.ssh 16 | .. #root 17 | - 18 | -sbin type=dir mode=0755 uname=root gname=wheel ignore 19 | -.. #sbin 20 | 21 | usr type=dir mode=0755 uname=root gname=wheel 22 | bin type=dir mode=0755 uname=root gname=wheel ignore 23 | -------------------------------------------------------------------------------- /rdroot/boottmp/mtree_special.mode1.diff: -------------------------------------------------------------------------------- 1 | --- special.orig Thu May 1 20:16:34 2025 2 | +++ special Fri May 2 08:40:30 2025 3 | @@ -12,6 +12,11 @@ 4 | mem type=char mode=0640 uname=root gname=kmem 5 | .. #dev 6 | 7 | +sbin type=link 8 | +usr type=link 9 | + 10 | +ram type=dir mode=0755 uname=root gname=wheel 11 | + 12 | etc type=dir mode=0755 uname=root gname=wheel 13 | acme-client.conf type=file mode=0644 uname=root gname=wheel optional 14 | bgpd.conf type=file mode=0600 uname=root gname=wheel optional 15 | @@ -129,36 +134,6 @@ 16 | .. #root/.ssh 17 | .. #root 18 | 19 | -sbin type=dir mode=0755 uname=root gname=wheel ignore 20 | -.. #sbin 21 | - 22 | -usr type=dir mode=0755 uname=root gname=wheel 23 | -bin type=dir mode=0755 uname=root gname=wheel ignore 24 | -.. #usr/bin 25 | -games type=dir mode=0755 uname=root gname=wheel optional 26 | -.. #usr/games 27 | -include type=dir mode=0755 uname=root gname=bin ignore 28 | -.. #usr/include 29 | -lib type=dir mode=0755 uname=root gname=wheel ignore 30 | -.. #usr/lib 31 | -libdata type=dir mode=0755 uname=root gname=wheel ignore 32 | -.. #usr/libdata 33 | -libexec type=dir mode=0755 uname=root gname=wheel 34 | -auth type=dir mode=0750 uname=root gname=auth ignore 35 | -.. #usr/libexec/auth 36 | -.. #usr/libexec 37 | -local type=dir mode=0755 uname=root gname=wheel 38 | -bin type=dir mode=0755 uname=root gname=wheel ignore 39 | -.. #usr/local/bin 40 | -lib type=dir mode=0755 uname=root gname=wheel ignore 41 | -.. #usr/local/lib 42 | -.. #usr/local 43 | -sbin type=dir mode=0755 uname=root gname=wheel ignore 44 | -.. #usr/sbin 45 | -share type=dir mode=0755 uname=root gname=wheel ignore 46 | -.. #usr/share 47 | -.. #usr 48 | - 49 | var type=dir mode=0755 uname=root gname=wheel 50 | account type=dir mode=0755 uname=root gname=wheel 51 | acct type=file mode=0644 uname=root gname=wheel optional 52 | @@ -214,3 +189,5 @@ 53 | output type=dir mode=0755 uname=root gname=wheel ignore 54 | .. #var/spool/output 55 | .. #var/spool 56 | +.. #var 57 | +.. #ram 58 | -------------------------------------------------------------------------------- /rdroot/boottmp/mtree_special.mode2.diff: -------------------------------------------------------------------------------- 1 | --- special.orig Thu May 1 20:16:34 2025 2 | +++ special Fri May 2 08:44:25 2025 3 | @@ -12,6 +12,8 @@ 4 | mem type=char mode=0640 uname=root gname=kmem 5 | .. #dev 6 | 7 | +ram type=dir mode=0755 uname=root gname=wheel 8 | + 9 | etc type=dir mode=0755 uname=root gname=wheel 10 | acme-client.conf type=file mode=0644 uname=root gname=wheel optional 11 | bgpd.conf type=file mode=0600 uname=root gname=wheel optional 12 | -------------------------------------------------------------------------------- /rdroot/boottmp/rc: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2005--2025, Yoshihiro Kawamata 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in 13 | # the documentation and/or other materials provided with the 14 | # distribution. 15 | # 16 | # * Neither the name of Yoshihiro Kawamata nor the names of its 17 | # contributors may be used to endorse or promote products derived 18 | # from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | #==================== 34 | # interim rc file for LiveCD 35 | # 36 | # KAWAMATA, Yoshihiro 37 | # kaw@on.rim.or.jp 38 | # 39 | 40 | #==================== 41 | # Global Definitions 42 | #==================== 43 | init_args="$@" 44 | osrel=`sysctl -n kern.osrelease` 45 | osmac=`sysctl -n hw.machine` 46 | 47 | #------------------------------- 48 | # make a list of all partitions 49 | # 50 | scan_disks () { 51 | 52 | #------------------------------- 53 | # make a list of all partitions 54 | # 55 | for dsk in `sysctl -n hw.disknames | /boottmp/sed -E -e 's/:[0-9a-f]+/:/g; s/[:,]+/ /g;'`; do 56 | case $dsk in 57 | [csw]d[0-9]*) 58 | disklabel -c -pm $dsk 2> /dev/null \ 59 | | /boottmp/sed -E -e '/^ [abd-p]: /!d; s/^ (.):/'$dsk'\1/' 60 | ;; 61 | esac 62 | done > /boottmp/boot_partitions 63 | 64 | 65 | #------------------------------- 66 | # inspecting every disk partitions 67 | # 68 | echo -n "scanning partitions:" 69 | unset partlst part_sys part_sto part_enc part_swp part_noask 70 | while read ln; do 71 | set -- $ln 72 | part="$1" 73 | fstype="$4" 74 | partlst=${partlst:+"$partlst "}$part 75 | echo -n " $part" 76 | case $fstype in 77 | swap) 78 | part_swp=${part_swp:+"$part_swp "}$part 79 | ;; 80 | RAID) 81 | # search string 'SR CRYPTO' at head of partition 82 | # We cannot use "fgrep -q" because bin dirs not mounted yet. 83 | # 84 | if [ "`dd if=/dev/r$part bs=1k skip=8 count=1 2>/dev/null | /boottmp/sed -e '/SR CRYPTO/!d; s/.*SR CRYPTO.*/FOUND/'`" \ 85 | = 'FOUND' ]; then 86 | part_enc=${part_enc:+"$part_enc "}$part 87 | fi 88 | ;; 89 | 4.2BSD|ISO9660|MSDOS|NTFS|ext2fs) 90 | if mount -r /dev/$part /mnt 2> /dev/null; then 91 | set -- /mnt/ISO/FuguIta-${osrel}-${osmac}-?????????.iso 92 | if [ -f /mnt/fuguita-${osrel}-${osmac}.ffsimg -o ! X"$1" = X"/mnt/ISO/FuguIta-${osrel}-${osmac}-?????????.iso" ]; then 93 | part_sys=${part_sys:+"$part_sys "}$part 94 | fi 95 | if [ -d /mnt/livecd-config ]; then 96 | part_sto=${part_sto:+"$part_sto "}$part 97 | fi 98 | if [ -r /mnt/livecd-config/${osrel}/${osmac}/noasks ]; then 99 | # set local parameters to null 100 | local noask_rdev noask_umem noask_setup_rw_mode noask_confdev noask_confdata # define local parameters 101 | unset noask_rdev noask_umem noask_setup_rw_mode noask_confdev noask_confdata # after unset, they become global 102 | local noask_rdev noask_umem noask_setup_rw_mode noask_confdev noask_confdata # so redefine them as local 103 | . /mnt/livecd-config/${osrel}/${osmac}/noasks 104 | if [ "X${noask_rdev}${noask_umem}${noask_setup_rw_mode}${noask_confdev}${noask_confdata}" != X ]; then 105 | # any of noask parameters is set 106 | part_noask=${part_noask:+"$part_noask "}${part}:/livecd-config/${osrel}/${osmac}/noasks 107 | fi 108 | fi 109 | umount /dev/$part 110 | fi 111 | ;; 112 | esac 113 | done < /boottmp/boot_partitions 114 | echo 115 | } 116 | 117 | #------------------------------- 118 | # parse - convert size with factor to megabytes 119 | # 120 | # usage: parsesize factored-size memory-size(MB) swap-size(MB) 121 | # 122 | # factors: n|n[Mm] - n megabytes 123 | # n[kK] - n kilobytes 124 | # n[gG] - n gigabytes 125 | # n% - n percent of memory-size 126 | # n%% - n percent of (memory-size+swap-size) 127 | # 128 | # The result will be output to stdout with megabyte value 129 | # null string returned if conversion fails 130 | # 131 | parsesize () { 132 | local umem="$1"; shift 133 | local maxmem="$1"; shift 134 | local swpmem="$1"; shift 135 | 136 | local d0='[0-9]' 137 | local d1='[1-9]' 138 | local k='[kK]' 139 | local m='[mM]' 140 | local g='[gG]' 141 | 142 | case "$umem" in 143 | $d0|$d1$d0|$d1$d0$d0|$d1$d0$d0$d0|$d1$d0$d0$d0$d0) # up to 99999(MB) 144 | echo $umem 145 | ;; 146 | $d0$k|$d1$d0$k|$d1$d0$d0$k|$d1$d0$d0$d0$k|$d1$d0$d0$d0$d0$k|$d1$d0$d0$d0$d0$d0$k|$d1$d0$d0$d0$d0$d0$d0$k|$d1$d0$d0$d0$d0$d0$d0$d0$k) # up to 99999999KB 147 | echo $((${umem%?}/1024)) 148 | ;; 149 | $d0$m|$d1$d0$m|$d1$d0$d0$m|$d1$d0$d0$d0$m|$d1$d0$d0$d0$d0$m) # up to 99999MB 150 | echo ${umem%?} 151 | ;; 152 | $d0$g|$d1$d0$g|$d1$d0$d0$g) # up to 999GB 153 | echo $((1024*${umem%?})) 154 | ;; 155 | $d0%%|$d1$d0%%|100%%) 156 | echo $((${umem%??}*(maxmem+swpmem)/100)) 157 | ;; 158 | $d0%|$d1$d0%|100%) 159 | echo $((${umem%?}*maxmem/100)) 160 | ;; 161 | *) 162 | esac 163 | } 164 | 165 | #------------------------------- 166 | # duid2dev - convert DUID.partition expression to DEVpartition 167 | # e.g. 7df1e3007af31be5.a -> sd0a 168 | # sd0a -> sd0a 169 | # anything else -> NULL STRING 170 | # 171 | function duid2dev { 172 | devpart="$1" 173 | case X"$devpart"X in 174 | X[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[ad-p]X) 175 | # DUID expression - convert 176 | duid=${devpart%??} 177 | part=${devpart#?????????????????} 178 | 179 | local seendevs ddev matchdev 180 | 181 | OIFS="$IFS" 182 | IFS=',' 183 | for dkname in `sysctl -n hw.disknames`; 184 | do 185 | dev=${dkname%:*} 186 | id=${dkname#*:} 187 | 188 | # warn DUID duplication 189 | # 190 | if [[ -n "$seendevs" && 191 | -n "$id" && 192 | "$seendevs" = *":$id"* ]]; then 193 | ddev=${seendevs%%:${id}*} 194 | ddev=${ddev##* } 195 | echo "Warning: $ddev and $dev have the same DUID - $id" >&2 196 | fi 197 | seendevs=${seendevs:+"$seendevs "}"$dev:$id" 198 | 199 | # DUID matched - emit devname 200 | # 201 | if [ "$duid" = "$id" ]; then 202 | matchdev="$dev$part" 203 | fi 204 | done 205 | IFS="$OIFS" 206 | 207 | [ -z "$ddev" ] && echo "$matchdev" 208 | ;; 209 | X[cws]d[0-9][ad-p]X|X[cws]d[1-9][0-9][ad-p]X) 210 | # DEV expression - no convert 211 | echo "$devpart" 212 | ;; 213 | XX) 214 | ;; 215 | *) 216 | # ILLEGAL expression 217 | echo "Warning: Illegal format for a disk partition - \"$devpart\"" >&2 218 | ;; 219 | esac 220 | } 221 | 222 | #------------------------------- 223 | # make shadow directory 224 | # 225 | # mkshadowdir orig-dir shadow-dir 226 | # 227 | mkshadowdir() { 228 | local srcdir="$1" 229 | local destdir="$2" 230 | 231 | # error checks 232 | [ -n "$destdir" ] || return # no enough arguments 233 | [ -d "$srcdir" ] || return # non existent srcdir 234 | mkdir -p "$destdir" || return # can't make destdir 235 | 236 | # make shadow directory tree 237 | lndir -s "$srcdir" "$destdir" 238 | 239 | # fix permissions and time stamps of target directories 240 | # 241 | # Note: 242 | # If the last output line of 'mtree -cdtq' starts with '..', 243 | # it will be deleted by sed. 244 | # This is because 'mtree -edtq' complains about such lines when 245 | # source directory is empty. 246 | mtree -p "$srcdir" -cdtq \ 247 | | sed -e '${/^\.\.$/{d;};}' \ 248 | | mtree -p "$destdir" -edtq -u > /dev/null 249 | } 250 | 251 | 252 | #------------------------------- 253 | # return lesser value from two positive integer 254 | # returns null string when error occurred 255 | # 256 | min () { 257 | [[ -z "$1" ]] && return 258 | [[ -z "$2" ]] && return 259 | 260 | if [[ "$1" -lt "$2" ]]; then 261 | echo "$1" 262 | else 263 | echo "$2" 264 | fi 265 | } 266 | 267 | 268 | #==================== 269 | # Active code from here 270 | #==================== 271 | # setup file systems; 272 | # 1. / ... rd - ram disk attached to kernel 273 | # 2. /sysmedia ... CD or USB flashdrive - containing FFS system image 274 | # 3. /fuguita ... vnode disk - mounted FFS system image 275 | # 4. /ram ... user-modifiable file system 276 | # 277 | 278 | cd / 279 | 280 | #------------------------------- 281 | # setup root fs and record starting timestamp of boot 282 | # 283 | mount -w /dev/rd0a / 284 | : > /boottmp/boot_starts 285 | 286 | #---------------------------- 287 | # detect boot-failure loop 288 | # 289 | if [ -r /boottmp/boot_tries ]; then 290 | read boot_tries < /boottmp/boot_tries 291 | boot_tries=$((boot_tries+1)) 292 | else 293 | boot_tries=1 294 | fi 295 | 296 | if [ $boot_tries -ge 10 ]; then 297 | echo 'Boot retries exceeded.' 298 | echo -n 'emergency stop ->'; read dummy 299 | boot_tries=0 300 | fi 301 | echo $boot_tries > /boottmp/boot_tries 302 | 303 | #------------------------------- 304 | # ask which system-stored device is. 305 | # 306 | echo ' 307 | ================================================== 308 | = ______ __ _ 309 | = / ____/ | |_| |__ 310 | = / /____ ______ __ _| /_ _/_____ 311 | = / ___/ / / / __ \/ / / | | | | / _ | 312 | = / / / /_/ / /_/ / /_/ /| | | |_| (_) |__ 313 | = /_/ \____/\__ /\____/ |__| \___/____/__/ 314 | = __/ / 315 | = /___/ 316 | = 317 | = Welcome to FuguIta - OpenBSD-based Live System 318 | = https://fuguita.org/ 319 | =================================================== 320 | ' 321 | 322 | scan_disks 323 | 324 | #------------------------------- 325 | # set noask parameters 326 | # from a single noasks file 327 | # 328 | set -- $part_noask 329 | if [ $# -eq 1 ]; then 330 | if [ ! X"$1" = X ] && 331 | mount -r /dev/${1%%:*} /mnt; then # strip after ":" from "devname:path" 332 | if [ -r /mnt/livecd-config/${osrel}/${osmac}/noasks ]; then 333 | . /mnt/livecd-config/${osrel}/${osmac}/noasks 334 | fi 335 | umount /mnt 336 | fi 337 | elif [ $# -gt 1 ]; then 338 | echo "Warning: multiple noask files found: " 339 | for f in $part_noask; do 340 | echo " $f" 341 | done 342 | echo "disabling non-interactive boot ..." 343 | fi 344 | 345 | #------------------------------- 346 | # wait for cancelling non-interactive boot 347 | # 348 | if [ "X${noask_rdev}${noask_umem}${noask_setup_rw_mode}${noask_confdev}${noask_confdata}" != X ]; then 349 | trap "unset noask_rdev noask_umem noask_setup_rw_mode noask_confdev noask_confdata; echo ' ... cancelled'" 2 350 | echo "Press ^C to cancel non-interactive boot" 351 | sleep 5 352 | fi 353 | trap - 2 354 | 355 | 356 | #------------------------------- 357 | # ask user for FuguIta's operating device 358 | # 359 | if [ X"$part_sys" = X ]; then 360 | echo "Warning: None of FuguIta's operating device(s) found." 361 | else 362 | echo "FuguIta's operating device(s): ${part_sys}." 363 | set -- $part_sys 364 | if [ $# -eq 1 ]; then 365 | def_rdev="$1" 366 | fi 367 | fi 368 | 369 | noask_rdev=`duid2dev $noask_rdev` 370 | if [ X = X"$noask_rdev" ]; then 371 | while :; do 372 | echo 373 | echo -n "Which is FuguIta's operating device? ${def_rdev:+[default: ${def_rdev}] }-> " 374 | read rdev 375 | [ -n "${def_rdev}${rdev}" ] && break 376 | done 377 | [ -z "${rdev}" ] && rdev="$def_rdev" 378 | else 379 | echo "Which is FuguIta's operating device? -> $noask_rdev" 380 | rdev="$noask_rdev" 381 | noask_rdev='' 382 | fi 383 | 384 | 385 | #------------------------------- 386 | # mount system-stored device 387 | # 388 | vn_devname="vnd5" 389 | vn_devname_iso="vnd4" 390 | 391 | /sbin/mount -r /dev/${rdev} /fuguita || exit 392 | if [ -f /fuguita/fuguita-${osrel}-${osmac}.ffsimg ]; then 393 | /sbin/umount /fuguita 394 | /sbin/mount -r /dev/${rdev} /sysmedia 395 | /sbin/vnconfig ${vn_devname} /sysmedia/fuguita-${osrel}-${osmac}.ffsimg 396 | /sbin/mount -r /dev/${vn_devname}a /fuguita 397 | elif [ -d /fuguita/ISO ]; then 398 | /sbin/umount /fuguita 399 | /sbin/mount -r /dev/${rdev} /sysmedia 400 | set -- /sysmedia/ISO/FuguIta-${osrel}-${osmac}-?????????.iso 401 | shift $(($# - 1)) 402 | if [ ! X"$1" = X -a \ 403 | ! X"$1" = "X/sysmedia/ISO/FuguIta-${osrel}-${osmac}-?????????.iso" ] ;then 404 | umount /sysmedia 405 | mount -r /dev/${rdev} /sysmedia-iso 406 | /sbin/vnconfig ${vn_devname_iso} /sysmedia-iso/ISO/${1##*/} 407 | /sbin/mount -r /dev/${vn_devname_iso}a /sysmedia 408 | /sbin/vnconfig ${vn_devname} /sysmedia/fuguita-${osrel}-${osmac}.ffsimg 409 | /sbin/mount -r /dev/${vn_devname}a /fuguita 410 | fi 411 | fi 412 | 413 | #------------------------------- 414 | # read global system configurations 415 | # 416 | if [[ -r /fuguita/etc/fuguita/global.conf ]]; then 417 | . /fuguita/etc/fuguita/global.conf # for $mfs_max_mb 418 | fi 419 | 420 | #------------------------------- 421 | # get ram size in MB 422 | # 423 | maxmem=$(($(sysctl -n hw.physmem)/1024/1024)) 424 | 425 | #------------------------------- 426 | # activate swap partition(s) 427 | # 428 | if [ -n "$part_swp" ]; then 429 | for swdev in $part_swp; do 430 | echo "activating swap partition: /dev/$swdev" 431 | swapon /dev/$swdev 432 | if [[ "${rdev%?}" = "${swdev%?}" ]]; then 433 | # since rdev is a flash device, 434 | # reduce the write frequency of this swap partition 435 | swapctl -c -p 10000 "/dev/${swdev}" 436 | fi 437 | done 438 | fi 439 | # 440 | # get total swap size in MB 441 | # 442 | swpmem=$( (swapctl -lk; echo 'end') | while read dev size rest 443 | do 444 | if [[ "$dev" = 'end' ]]; then 445 | echo $((totsize/1024)) 446 | elif [[ "$dev" = 'Device' ]]; then 447 | : 448 | elif [[ "$dev" = 'Total' ]]; then 449 | : 450 | else 451 | totsize=$((totsize+size)) 452 | fi 453 | done ) 2> /dev/null 454 | 455 | #------------------------------- 456 | # prompt for mfs/tmpfs size 457 | # 458 | memfstype=${memfstype:-mfs} # unless global.conf loaded 459 | 460 | while :; do 461 | echo "available memory: ${maxmem}M" 462 | [[ 0 -lt "$swpmem" ]] && echo "total swap size: ${swpmem}M" 463 | echo 464 | 465 | if [[ -n "$noask_umem" ]]; then # non-interactive value specified 466 | umem="$noask_umem" 467 | echo "${memfstype} size -> $umem" 468 | unset noask_umem # make unset for next loop 469 | 470 | umem=$(min "$mfs_max_mb" $(parsesize "$umem" $maxmem $swpmem)) 471 | else # manual setup 472 | echo -n "Enter ${memfstype} size" 473 | if [[ "$memfstype" = 'tmpfs' ]]; then 474 | defmem=0 475 | echo ' (0 is auto).' 476 | else 477 | defmem=$(min "$mfs_max_mb" $(parsesize '75%' $maxmem $swpmem)) 478 | echo '.' 479 | fi 480 | 481 | echo ' You can add suffix K, M, or G.' 482 | echo ' % is a percentage of memory size.' 483 | echo ' and %% is a percentage of the total memory and swap.' 484 | echo ' otherwise considered "megabytes"' 485 | echo 486 | echo -n "[default: ${defmem}M] -> "; read umem 487 | 488 | if [[ -z "$umem" ]]; then 489 | umem="$defmem" 490 | fi 491 | 492 | umem=$(min "$mfs_max_mb" $(parsesize "$umem" $maxmem $swpmem)) 493 | fi 494 | 495 | if [[ -n "$umem" ]]; then 496 | if [[ "$memfstype" = tmpfs && "$umem" -eq 0 ]]; then 497 | echo "set ${memfstype} size to auto" 498 | else 499 | echo "set ${memfstype} size to ${umem}MB" 500 | fi 501 | break; 502 | else 503 | echo "illegal input - try again" 504 | fi 505 | done 506 | 507 | 508 | #------------------------------- 509 | # create and mount memory-based file system 510 | # 511 | if [[ "$memfstype" = 'tmpfs' ]]; then 512 | /fuguita/sbin/mount_tmpfs -s ${umem}M -o wxallowed tmpfs /ram || exit 513 | else 514 | # mount_mfs exists on in-kernel FS 515 | # to be able to umount /fuguita at boot mode 2 516 | /boottmp/mount_mfs -s $((2*1024*umem)) -o wxallowed swap /ram || exit 517 | fi 518 | 519 | #------------------------------- 520 | # generate fstab from current 521 | # mounting status 522 | # 523 | echo "# generated automatically at boot time" > /boottmp/fstab 524 | /sbin/mount | \ 525 | while read ln; do 526 | set - $ln 527 | case X"$3"X in 528 | X/X) 529 | echo /dev/rd0a / ffs rw 0 0 ;; 530 | X/fuguitaX|X/sysmediaX) 531 | echo $1 $3 $5 ro 0 0 ;; 532 | X/ramX) 533 | echo $memfstype $3 $5 rw,wxallowed 0 0 ;; 534 | *) 535 | echo $1 $3 $5 defaults 0 0 ;; 536 | esac 537 | done >> /boottmp/fstab 538 | 539 | #---------------------------- 540 | # re-link bin dirs to System device 541 | # 542 | /fuguita/bin/rm -rf /bin /sbin 543 | /fuguita/bin/ln -sf fuguita/bin fuguita/sbin . 544 | 545 | while :; do 546 | 547 | #---------------------------- 548 | # detect select-mode failure loop 549 | # 550 | if [ "X$select_mode_tries" = X ]; then 551 | select_mode_tries=1 552 | else 553 | select_mode_tries=$(($select_mode_tries+1)) 554 | fi 555 | 556 | if [ $select_mode_tries -ge 10 ]; then 557 | echo 'Too many boot retries.' 558 | echo -n 'emergency stop ->'; read dummy 559 | unset select_mode_tries 560 | fi 561 | 562 | #---------------------------- 563 | # boot modes 564 | # 565 | echo 566 | echo 'Boot modes:' 567 | echo ' 0: fresh boot - standard mode as a live system' 568 | echo ' 1: fresh boot - less memory, faster boot' 569 | echo " (/usr is non-writable, can't pkg_add)" 570 | echo ' 2: fresh boot - works using only RAM' 571 | echo ' (about 1GB or more of RAM required)' 572 | echo ' 3: boot with retrieving saved files from storage device' 573 | echo ' or enter passphrase for an encrypted volume' 574 | echo ' 4: boot with retrieving saved files from floppy disk' 575 | echo ' 5: interactive shell for maintenance' 576 | echo -n '-> ' 577 | if [ X = X"$noask_setup_rw_mode" ]; then 578 | read setup_rw_mode 579 | else 580 | echo $noask_setup_rw_mode 581 | setup_rw_mode="$noask_setup_rw_mode" 582 | noask_setup_rw_mode='' 583 | fi 584 | 585 | case X"$setup_rw_mode" in 586 | 587 | #----------------------- 588 | #----------------------- 589 | # System Storage only mode 590 | #----------------------- 591 | #----------------------- 592 | # 593 | X[012]) 594 | if [ X"$setup_rw_mode" = X0 ]; then 595 | echo "manual" 596 | elif [ X"$setup_rw_mode" = X1 ]; then 597 | echo "manual_less_ram" 598 | elif [ X"$setup_rw_mode" = X2 ]; then 599 | echo "manual_more_ram" 600 | fi > /boottmp/boot_mode 601 | 602 | #------------------------------------- 603 | # copy System Storage contents to rw-able file system 604 | # 605 | echo "Running manual setup." 606 | echo -n "Copying system files to /ram ... " 607 | cd /ram 608 | if [ X"$setup_rw_mode" = X0 ]; then 609 | (cd ../fuguita && tar cf - altroot etc home tmp root var) | tar xpf - 610 | elif [ X"$setup_rw_mode" = X1 ]; then 611 | (cd ../fuguita && tar cf - altroot etc home tmp root var) \ 612 | | tar -x \ 613 | -p \ 614 | -f - \ 615 | -s '|^etc/X11/.*||' \ 616 | -s '|^var/db/pkg/.*||' \ 617 | -s '|^var/www/htdocs/.*||' 618 | elif [ X"$setup_rw_mode" = X2 ]; then 619 | (cd ../fuguita && pax -rwpe . /ram/. && cd /) 620 | fi 621 | echo "done" 622 | 623 | #----------------------- 624 | # symlink from / to ram 625 | # 626 | cd / 627 | rm -rf /tmp 628 | mv /etc /bootetc 629 | ln -sf ram/* . 2> /dev/null 630 | cp /boottmp/fstab /etc 631 | 632 | #------------------------------------------- 633 | # symlink rest of contents from / to System Storage 634 | # 635 | ln -s fuguita/* . 2> /dev/null 636 | #ln -s fuguita/.??* . 2> /dev/null ; # Maybe not needed 637 | 638 | 639 | # modify /etc/mtree/special 640 | # 641 | if [ -r /boottmp/mtree_special.mode${setup_rw_mode}.diff ]; then 642 | cat /boottmp/mtree_special.mode${setup_rw_mode}.diff | ( cd /etc/mtree && patch -s ) 643 | fi 644 | 645 | if [ X"$setup_rw_mode" = X0 ]; then 646 | #------------------------------------------- 647 | # extract pre-build symlinks archive 648 | # or lndir from /ram/usr to /fuguita/usr 649 | # 650 | if [ -r /fuguita/etc/fuguita/mode0symlinks.cpio.gz \ 651 | -a ! -e /boottmp/force_lndir ]; then 652 | echo -n "Extracting symlinks from /ram to /fuguita ... " 653 | ( cd /ram \ 654 | && pax -rzpe -f /fuguita/etc/fuguita/mode0symlinks.cpio.gz \ 655 | && [ -r /etc/mtree/special ] \ 656 | && mtree -edtq -u -p / -f /etc/mtree/special > /dev/null ) 657 | else 658 | echo -n "Linking files from /ram to /fuguita ... " 659 | mkshadowdir /fuguita/usr /ram/usr 660 | fi 661 | 662 | #------------------------------------------- 663 | # Replace symlinks to directories and files 664 | # 665 | for d in \ 666 | usr/libexec/auth 667 | do 668 | if [ -d /fuguita/$d ]; then 669 | rm -rf /ram/$d && cd $(dirname /fuguita/$d) && pax -rwpe $(basename $d) $(dirname /ram/$d) 670 | fi 671 | done 672 | 673 | #------------------------------------------- 674 | # Replace symlinks to ordinary files 675 | # 676 | for f in \ 677 | usr/local/info/dir \ 678 | usr/local/share/info/dir \ 679 | usr/local/man/mandoc.db \ 680 | usr/local/libdata/perl5/site_perl/OpenBSD/Quirks.pm \ 681 | usr/local/libdata/perl5/site_perl/OpenBSD/Quirks/ghc.pm \ 682 | usr/fuguita/man/mandoc.db \ 683 | usr/fuguita/share/man/mandoc.db 684 | do 685 | if [ -f /fuguita/$f ]; then 686 | rm -f /ram/$f && cp -p /fuguita/$f /ram/$f 687 | fi 688 | done 689 | 690 | #------------------------------------------- 691 | # Replace directories to symlinks 692 | # 693 | # to from 694 | set -- /fuguita/usr/X11R6/lib/X11/fonts /ram/usr/X11R6/lib/X11/fonts \ 695 | /etc/X11/app-defaults /ram/usr/local/lib/X11/app-defaults 696 | 697 | while [ -n "$1" -a -n "$2" ] 698 | do 699 | if [ -d "$1" -a -d "$2" ]; then 700 | rm -r "$2" 701 | ln -s "$1" "$2" 702 | fi 703 | shift 2 704 | done 705 | 706 | cd / && ln -sf ram/usr . 707 | elif [ X"$setup_rw_mode" = X1 ]; then 708 | mkshadowdir /fuguita/etc/X11 /ram/etc/X11 709 | mkshadowdir /fuguita/var/db/pkg /ram/var/db/pkg 710 | mkshadowdir /fuguita/var/www/htdocs /ram/var/www/htdocs 711 | fi 712 | 713 | echo "done" 714 | 715 | #======================================== 716 | # Configurations under /etc 717 | #======================================== 718 | 719 | #--------------- 720 | # keyboard type 721 | # 722 | if dmesg | grep -q '^.* at .*: console keyboard'; then 723 | while :; do 724 | 725 | # display list of kb encodings 726 | # (note that sed don't handle \n in replace string) 727 | # 728 | echo `kbd -l` | sed -e 's/tables available for \([^ ][^ ]*\) keyboard: encoding /\ 729 | \ 730 | \1 keyboard:\ 731 | /g' | sed -e '1s/.*/\ 732 | Enter keyboard type./' 733 | 734 | echo -n 'keyboard type -> '; read kbtype 735 | if kbd $kbtype; then 736 | echo $kbtype > /etc/kbdtype 737 | break 738 | fi 739 | done 740 | fi 741 | 742 | #------------------------------ 743 | # serial console (for vmm/vmd) 744 | # 745 | if dmesg | grep -q '^com0: console'; then 746 | ttyspeed=`stty speed` 747 | sed -i.orig \ 748 | -e '/^console/s|[ ]on| off|; 749 | s|^tty00[ ].*|tty00 "/usr/libexec/getty std.'${ttyspeed}'" vt220 on secure|' \ 750 | /etc/ttys 751 | fi 752 | 753 | #------------------------------ 754 | # put customized man.conf at mode 0 755 | # 756 | if [ X"$setup_rw_mode" = X0 ]; then 757 | cat </etc/man.conf 758 | # comment out if the man directory is empty 759 | # 760 | manpath /fuguita/usr/share/man 761 | manpath /fuguita/usr/X11R6/man 762 | manpath /fuguita/usr/local/man 763 | manpath /fuguita/usr/fuguita/man 764 | manpath /fuguita/usr/fuguita/share/man 765 | manpath /usr/local/man 766 | manpath /usr/fuguita/man 767 | manpath /usr/fuguita/share/man 768 | EOT 769 | else 770 | rm -f /etc/man.conf 771 | fi 772 | 773 | #--------------- 774 | # root password 775 | # 776 | echo 777 | until passwd root 778 | do 779 | echo "passwd failed, Try again." 780 | done 781 | 782 | #------------------------ 783 | # create /etc/fuguita related stuffs 784 | # 785 | mkdir -p /etc/fuguita/netconfs/templ.{head,tail} # may already be created 786 | cat > /etc/fuguita/netconfs/templ.head/sysctl.conf < /etc/fuguita/netconfs/templ.head/hosts < '; read ans 827 | case "$ans" in 828 | [Xx]*) echo 'xenodm_flags=' >> /etc/rc.conf.local 829 | ;; 830 | esac 831 | ;; 832 | esac 833 | 834 | # modify OpenBSD's orignal /etc/{rc,login.conf} 835 | # 836 | (if cd /etc; then 837 | patch -s < /boottmp/etc.rc.diff 838 | patch -s < /boottmp/etc.login.conf.diff 839 | fi) 840 | 841 | # create misc stuffs 842 | # 843 | ln -sf /usr/share/zoneinfo/UTC /etc/localtime 844 | echo 'https://cdn.openbsd.org/pub/OpenBSD' > /etc/installurl 845 | echo '/usr/sbin/fw_update -v' > /etc/rc.firsttime 846 | cat < /etc/rc.shutdown 847 | force_umount=No # set Yes for forced umount /ram at shutdown 848 | force_resync=No # set Yes to re-sync at shutdown 849 | 850 | # list of daemons 851 | # both heading and trailing spaces needed for pattern match 852 | # 853 | skip_daemons=' mountd ' # skipped in stop_daemons() 854 | kill_daemons=' mountd ' # -KILLed in kill_daemons() 855 | 856 | # stop_daemons - to eliminate all daemons before usbfadm_r 857 | # 858 | stop_daemons () { 859 | echo -n 'stopping daemons:' 860 | for srv in \$(rcctl ls started); do 861 | if ! expr "\$skip_daemons" : ".* \$srv " >/dev/null ; then 862 | rcctl stop \$srv 863 | fi 864 | done 865 | echo "\ndone." 866 | } 867 | 868 | # kill_daemons - to eliminate all daemons at umount /ram 869 | # 870 | kill_daemons () { 871 | ulimit -c 0 # to avoid useless coredumps 872 | for srv in \$kill_daemons; do 873 | pkill -KILL \$srv 874 | done 875 | } 876 | 877 | # usbfadm_r - perform re-sync of the usbfadm utility 878 | # 879 | # This function calls usbfadm's sync function on shutdown to 880 | # synchronize the contents of the USB stick with ${memfstype}. 881 | # If usbfadm is incompletely configured, this function will invoke a 882 | # sub-shell to prompt for configuration and saving by usbfadm. 883 | # If re-synchronisation fails repeatedly, it will still launch a 884 | # sub-shell for data preservation work, allowing the user to remove 885 | # the cause of the error and perform usbfadm sync manually or by other 886 | # means to preserve the data. 887 | # 888 | usbfadm_r () { 889 | ( # Invoking auto-save process in a subshell 890 | 891 | export PATH=\$PATH:/usr/local/bin:/usr/local/bin:/usr/fuguita/sbin:/usr/fuguita/bin 892 | 893 | # check if 'saveas' is set 894 | # 895 | if [[ -z \$(/dev/null; then 896 | echo "= The 'saveas' of usbfadm utility is not set." 897 | echo "= Please do 'saveas' then 'sync' in the interactive mode of usbfadm." 898 | echo = invoking interactive shell for emergency... 899 | PS1="(emg) \$PS1" /bin/ksh -li 900 | fi 901 | 902 | # usbfadm with retry loop 903 | # 904 | retry=0 905 | retrymax=3 906 | waitsec=5 907 | ulimit -d unlimited # prevent rsync from failing 908 | ulimit -m unlimited # due to lack of memory 909 | while ! /usr/fuguita/sbin/usbfadm -r; do 910 | retry=\$((retry+1)) 911 | if [ \$retry -ge \$retrymax ]; then 912 | echo = too many failures of usbfadm 913 | echo = invoking interactive shell for emergency 914 | PS1="(emg) \$PS1" /bin/ksh -li 915 | retry=0 # reset retry loop then do again... 916 | else 917 | echo usbfadm failed, 918 | fi 919 | echo will retry after \$waitsec seconds... 920 | sleep \$waitsec 921 | done ) 922 | } 923 | 924 | [[ "\$force_umount" = [Yy][Ee][Ss] ]] && stop_daemons 925 | 926 | # not to set default 'saveas' when archive deployed 927 | # to avoid misoperation of usbfadm sync 928 | if [[ \$(cat /boottmp/boot_mode) != usbflash_arc ]]; then 929 | [[ "\$force_resync" = [Yy][Ee][Ss] ]] && usbfadm_r 930 | fi 931 | 932 | kill_daemons 933 | [[ "\$force_umount" = [Yy][Ee][Ss] ]] && /boottmp/umount -f /ram 934 | EOT 935 | # motd 936 | # 937 | cat < /etc/motd 938 | OpenBSD ?.? (UNKNOWN) 939 | 940 | Welcome to FuguIta, the OpenBSD-based live system. 941 | 942 | FuguIta aims to help popularize OpenBSD operating system by making it easier 943 | to get started with. 944 | 945 | For information on FuguIta's specific features and how to use them, please 946 | refer to the documentation on https://fuguita.org/. 947 | 948 | If you have any questions or suggestions for FuguIta, please send an email to 949 | me or post a message to fuguita.org's message board. 950 | Please feel free to contact me. 951 | 952 | Yoshihiro Kawamata 953 | kaw@on.rim.or.jp , https://fuguita.org/ 954 | 955 | EOT 956 | 957 | #======================================== 958 | # Configurations under misc dir 959 | #======================================== 960 | # 961 | cat <> /etc/skel/.profile 962 | 963 | PATH=\$PATH:/usr/fuguita/sbin:/usr/fuguita/bin 964 | export PATH 965 | EOT 966 | install -o root -g wheel -m 0600 /dev/null /root/.Xauthority 967 | install -o root -g wheel -m 0600 /dev/null /etc/skel/.Xauthority 968 | dd if=/dev/random of=/var/db/host.random bs=64k count=1 2>/dev/null 969 | chown root:wheel /var/db/host.random 970 | chmod 0600 /var/db/host.random 971 | 972 | break 973 | ;; 974 | 975 | #----------------------- 976 | #----------------------- 977 | # Restore from USB flash mode 978 | #----------------------- 979 | #----------------------- 980 | # 981 | X3) 982 | echo "usbflash" > /boottmp/boot_mode 983 | 984 | #----------------------- 985 | # Re-scan and build device list 986 | # 987 | scan_disks 988 | 989 | #------------------------------- 990 | # ask user for FuguIta's operating device 991 | # 992 | if [ -z "${part_sto}${part_enc}" ]; then 993 | echo "Warning: None of FuguIta's storage device(s) found." 994 | continue 995 | else 996 | # display concerning devices 997 | echo "Device(s) found:" 998 | if [ -n "${part_sto}" ]; then 999 | echo " loadable from: ${part_sto}" 1000 | set -- $part_sto 1001 | if [ $# -eq 1 ]; then 1002 | def_sdev="$1" # single device only ... set default 1003 | else 1004 | unset def_sdev 1005 | fi 1006 | fi 1007 | if [ -n "${part_enc}" ]; then 1008 | echo " encrypted: ${part_enc}" 1009 | fi 1010 | fi 1011 | 1012 | noask_confdev=`duid2dev $noask_confdev` 1013 | if [ -z "$noask_confdev" ]; then 1014 | # manual input 1015 | # 1016 | echo 1017 | echo -n "Which is FuguIta's storage device? ${def_sdev:+[default: ${def_sdev}] }-> " 1018 | read sdev 1019 | 1020 | if [ -z "$sdev" ]; then 1021 | if [ -n "$def_sdev" ]; then 1022 | sdev="$def_sdev" 1023 | else 1024 | continue # not input / no default ... return to boot menu 1025 | fi 1026 | fi 1027 | else 1028 | # input from noasks 1029 | # 1030 | echo "Which is FuguIta's storage device? -> $noask_confdev" 1031 | sdev="$noask_confdev" 1032 | noask_confdev='' 1033 | fi 1034 | 1035 | # Is crypto volume selected? 1036 | # 1037 | if [ 0 -lt `expr " ${part_enc} " : ".* $sdev "` ]; then 1038 | if bioctl -c C -l /dev/$sdev softraid0; then 1039 | sleep 1 # wait for kernel messages printed 1040 | echo "Passphrase successful: Select boot mode again..." 1041 | sleep 1 1042 | fi 1043 | continue # return to boot mode menu 1044 | elif [ 0 -eq `expr " ${part_sto} " : ".* $sdev "` ]; then 1045 | echo "$sdev is not loadable" 1046 | continue # return to boot mode menu 1047 | fi 1048 | 1049 | usb_devname=/dev/${sdev} 1050 | echo "$usb_devname" > /boottmp/boot_restore_devname 1051 | 1052 | #----------------------- 1053 | # mount user's storage 1054 | # 1055 | usb_devname=`cat /boottmp/boot_restore_devname` 1056 | if mount -r "$usb_devname" /mnt; then 1057 | #----------------------- 1058 | # select config files 1059 | # 1060 | if [ ! -d /mnt/livecd-config ]; then 1061 | echo "cannot find config dir on $usb_devname" 1062 | umount "$usb_devname" 1063 | continue 1064 | fi 1065 | 1066 | while :; do 1067 | echo "$usb_devname : available data;" 1068 | (if cd /mnt/livecd-config; then 1069 | cd $osrel/$osmac 2> /dev/null 1070 | echo 1071 | echo $(ls | /boottmp/sed -e '/^noasks$/d') # print except noasks 1072 | echo 1073 | fi) 1074 | echo -n 'config name -> ' 1075 | if [ X = X"$noask_confdata" ]; then 1076 | read confdata 1077 | else 1078 | echo $noask_confdata 1079 | confdata="$noask_confdata" 1080 | noask_confdata='' 1081 | fi 1082 | 1083 | if [ X"$confdata" = X ]; then 1084 | echo 'conf dir not specified' 1085 | umount "$usb_devname" 1086 | continue 2 1087 | elif [ -d /mnt/livecd-config/$osrel/$osmac/$confdata -o \ 1088 | -f /mnt/livecd-config/$osrel/$osmac/$confdata -o \ 1089 | -d /mnt/livecd-config/$confdata ]; then 1090 | echo "$confdata" > /boottmp/boot_user_config 1091 | break 1092 | else 1093 | echo 'cannot find such data' 1094 | umount "$usb_devname" 1095 | continue 2 1096 | fi 1097 | done 1098 | 1099 | #----------------------- 1100 | # copying to ram 1101 | # 1102 | echo "Copying files from persistent storage to ram ... " 1103 | 1104 | # an archive file 1105 | if [ -f /mnt/livecd-config/$osrel/$osmac/$confdata ]; then 1106 | echo "usbflash_arc" > /boottmp/boot_mode # overwrite "usbflash" 1107 | if cd /ram; then 1108 | # locate crunched binary gzip to temporary /usr/bin 1109 | # because pax has fixed command search PATH in it. 1110 | # gzip must be included in PATH 1111 | mkdir -p /usr/bin 1112 | ln -s /boottmp/gzip /usr/bin 1113 | 1114 | if ! pax -rzpe < /mnt/livecd-config/$osrel/$osmac/$confdata; then 1115 | # tmpfs bug workaround 1116 | # will retry later 1117 | pax_arc_failed="yes" 1118 | fi 1119 | 1120 | # cleanup temporary /usr/bin/gzip 1121 | rm -rf /usr 1122 | fi 1123 | 1124 | # synced dir tree 1125 | elif cd /mnt/livecd-config/$osrel/$osmac/$confdata 2> /dev/null || \ 1126 | cd /mnt/livecd-config/$confdata; then 1127 | if ! pax -rwpe . /ram; then 1128 | # tmpfs bug workaround 1129 | # will retry later 1130 | pax_failed="yes" 1131 | fi 1132 | fi 1133 | echo "done" 1134 | 1135 | #----------------------- 1136 | # setup operational file/dir tree 1137 | # 1138 | cd / 1139 | rm -rf /tmp 1140 | mv /etc /bootetc 1141 | ln -sf ram/* . 2> /dev/null # connect /ram dirs to / 1142 | ln -s fuguita/* . 2> /dev/null # connect rest of dirs in System Storage to / 1143 | # 1144 | # tmpfs bug work around 1145 | # retry copying to ram again 1146 | # 1147 | if [ "$pax_failed" = "yes" ]; then 1148 | if cd /mnt/livecd-config/$osrel/$osmac/$confdata 2> /dev/null || \ 1149 | cd /mnt/livecd-config/$confdata; then 1150 | for i in 1 2 3; do # retry 3 time max 1151 | echo "Copying to ram was partially failed, retrying..." 1152 | if PATH=$PATH:/fuguita/usr/local/bin:/fuguita/usr/fuguita/bin \ 1153 | rsync -rlptgovHS . /ram/.; then 1154 | echo "done" 1155 | break 1156 | fi 1157 | done 1158 | fi 1159 | fi 1160 | cd / 1161 | umount /mnt 1162 | 1163 | cp /boottmp/fstab /etc # fix /etc/fstab 1164 | else 1165 | echo "Failed to mount user's storage" 1166 | continue 1167 | fi 1168 | 1169 | #------------------------------------------- 1170 | # merge user-defined fstab entries 1171 | # into auto generated /etc/fstab 1172 | # 1173 | fstab_tail="/etc/fuguita/fstab.tail" 1174 | fstab_merged="# followings are merged from $fstab_tail" 1175 | 1176 | if ! fgrep -q "$fstab_merged" /etc/fstab; then 1177 | if [ -r $fstab_tail ]; then 1178 | echo $fstab_merged >> /etc/fstab 1179 | cat $fstab_tail >> /etc/fstab 1180 | fi 1181 | fi 1182 | 1183 | break 1184 | ;; 1185 | 1186 | #----------------------- 1187 | #----------------------- 1188 | # Restore from floppy mode 1189 | #----------------------- 1190 | #----------------------- 1191 | # 1192 | X4) 1193 | echo "floppy" > /boottmp/boot_mode 1194 | 1195 | #----------------------- 1196 | # copying to ram 1197 | # 1198 | if mount -r /dev/fd0a /mnt; then 1199 | if [ -r /mnt/livecd-retr.sh.inc ]; then 1200 | cp -p /boottmp/livecd-retr.sh.inc /boottmp/livecd-retr.sh.inc.orig 1201 | cat /mnt/livecd-retr.sh.inc > /boottmp/livecd-retr.sh.inc 1202 | . /boottmp/livecd-retr.sh.inc 1203 | umount /mnt 1204 | else 1205 | echo "Retrieval script not found on fd0a." 1206 | umount /mnt 1207 | continue 1208 | fi 1209 | else 1210 | echo "Failed to read /mnt/livecd-config.tar.gz on /dev/fd0a" 1211 | continue 1212 | fi 1213 | 1214 | break 1215 | ;; 1216 | 1217 | #----------------------- 1218 | #----------------------- 1219 | # Interactive shell mode 1220 | #----------------------- 1221 | #----------------------- 1222 | # 1223 | X5) 1224 | echo "intr-shell" > /boottmp/boot_mode 1225 | echo "==INTERACTIVE SHELL MODE================ 1226 | = 1227 | = An interactive shell invoked for manual operation. 1228 | = Now, just System Storage mounted on /fuguita. 1229 | = 1230 | = After exit this shell, select boot mode again. 1231 | = 1232 | ========================================" 1233 | PATH="/fuguita/sbin:/fuguita/bin" /fuguita/bin/sh 1234 | ;; 1235 | 1236 | *) echo "What?" ;; 1237 | esac 1238 | done 1239 | 1240 | #==================== 1241 | # remove unused directories / files 1242 | # 1243 | rm -f /boot.catalog /cdboot /cdbr /rr_moved 1244 | rmdir /sysmedia-iso 2> /dev/null 1245 | 1246 | 1247 | #------------------------------------------- 1248 | # if the origin boot mode is 2: 1249 | # - unmount operating devices 1250 | # - deactivate swap partitions 1251 | # 1252 | if [ -d /ram/usr -a ! -L /ram/usr/fuguita/version ]; then 1253 | 1254 | # umount sysmedia - the device containing file tree 1255 | # 1256 | umount /fuguita 1257 | vnconfig -u ${vn_devname} 1258 | umount /sysmedia 1259 | 1260 | # umount ISO image file if mounted 1261 | # 1262 | if mount | grep -q "/sysmedia-iso"; then 1263 | vnconfig -u ${vn_devname_iso} 1264 | umount /sysmedia-iso 1265 | fi 1266 | 1267 | # modify /etc/fstab 1268 | # 1269 | egrep -v ' /(sysmedia|sysmedia-iso|fuguita) ' /etc/fstab > /etc/fstab.tmp 1270 | mv /etc/fstab.tmp /etc/fstab 1271 | 1272 | # deactivate swap partitions if any 1273 | # 1274 | swapctl -l \ 1275 | | awk '/^\/dev\// && $3 == 0 { 1276 | printf("deactivating swap partition: %s ", $1) 1277 | system("swapctl -d " $1) 1278 | printf("\n") }' 1279 | 1280 | # delete encrypted volume if any 1281 | # 1282 | bioctl softraid0 \ 1283 | | awk '/^softraid0 .* sd[0-9]/ { 1284 | printf("delete encrypted volume: %s ", $5) 1285 | system("bioctl -d " $5) 1286 | printf("\n") }' 1287 | 1288 | # check and report 1289 | # - umount all fs except RAM fs 1290 | # - all swap partitions deactivated 1291 | # - delete encrypted volumes 1292 | # 1293 | echo 'on-memory operation:' 1294 | if ! mount | egrep -v ' on (/ |/ram )' | grep -q '.' && \ 1295 | swapctl -l 2>&1 | grep -q 'no swap devices configured'; then 1296 | # mount & swap purged 1297 | if [ -z "`bioctl softraid0`" ]; then 1298 | # no encrypted volumes reside 1299 | echo ' You can remove all storage device(s).' 1300 | else 1301 | echo " encrypted volume not deleted yet." 1302 | sleep 5 1303 | fi 1304 | 1305 | else 1306 | echo " ${memfstype} still paged out ... You can't remove any storage device(s)." 1307 | sleep 5 1308 | fi 1309 | fi 1310 | 1311 | echo " _________________________________________________ 1312 | / Setup for FuguIta ends. / 1313 | / OpenBSD's boot sequence will follow. / 1314 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 1315 | date > /boottmp/boot_livecd_rc_ends 1316 | 1317 | #======================================== 1318 | # chain original /etc/rc 1319 | # 1320 | 1321 | exec /bin/ksh /etc/rc "$init_args" 1322 | -------------------------------------------------------------------------------- /rdroot/boottmp/remaster_dvd: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | #---------------------------------------- 4 | # remaster_dvd - Remastering FuguIta's LiveDVD 5 | # Yoshihiro Kawamata, kaw@on.rim.or.jp 6 | # $Id: remaster_dvd,v 1.2 2025/03/24 03:29:58 kaw Exp $ 7 | #---------------------------------------- 8 | 9 | # Copyright (c) 2021--2025 10 | # Yoshihiro Kawamata 11 | # 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions are 16 | # met: 17 | # 18 | # * Redistributions of source code must retain the above copyright 19 | # notice, this list of conditions and the following disclaimer. 20 | # 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in 23 | # the documentation and/or other materials provided with the 24 | # distribution. 25 | # 26 | # * Neither the name of Yoshihiro Kawamata nor the names of its 27 | # contributors may be used to endorse or promote products derived 28 | # from this software without specific prior written permission. 29 | # 30 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | # display help and exit 43 | # 44 | usage_exit () { 45 | echo "Usage: ${0##*/} [-m mfs|tmpfs]" >&2 46 | exit "$1" 47 | } 48 | 49 | # check command-line arguments 50 | # 51 | while getopts m: name 52 | do 53 | case $name in 54 | m) memfs=$OPTARG ;; 55 | ?) usage_exit 1 ;; 56 | esac 57 | done 58 | shift $(($OPTIND - 1)) 59 | 60 | if [[ -n "$1" ]]; then 61 | usage_exit 1 62 | fi 63 | 64 | case $memfs in 65 | mfs) altfs=tmpfs ;; 66 | tmpfs) altfs=mfs ;; 67 | ?*) usage_exit 1 ;; 68 | esac 69 | 70 | # parameters 71 | # 72 | projname=FuguIta 73 | version=$(uname -r) 74 | arch=$(uname -m) 75 | imgfile=$(echo ${projname} | tr A-Z a-z)-${version}-${arch}.ffsimg 76 | 77 | # files to be remastered 78 | # 79 | files="./boot 80 | ./bsd-fi 81 | ./bsd-fi.mp 82 | ./cdboot 83 | ./cdbr 84 | ./etc/boot.conf 85 | ./$imgfile" 86 | 87 | # check contents 88 | # 89 | for f in $files; do 90 | if [ ! -r $f ]; then 91 | nofiles="$nofiles $f" 92 | fi 93 | done 94 | if [[ -n "$nofiles" ]]; then 95 | echo "$0: missing files needed:$nofiles" >&2 96 | exit 1 97 | fi 98 | 99 | vn=$(vnconfig $imgfile) 100 | if [ -z "$vn" ]; then 101 | echo 'no available vnode device' >&2 102 | exit 1 103 | fi 104 | 105 | if mount /dev/${vn}a /mnt; then 106 | # get version string inside img file 107 | # 108 | isoname=$(&2 121 | else 122 | # rewrite the value 123 | echo "Changing file system of /ram: from $altfs to $memfs" >&2 124 | sed -i -e '1,$s/memfstype='$altfs'/memfstype='$memfs'/' /mnt/etc/fuguita/global.conf 125 | fi 126 | fi 127 | umount /mnt 128 | fi 129 | vnconfig -u $vn 130 | 131 | # do remastering 132 | # 133 | if [[ -e eficdboot ]]; then 134 | eficd_opt='-e eficdboot' 135 | else 136 | eficd_opt= 137 | fi 138 | 139 | mkhybrid -a -R -L -l -d -D -N \ 140 | -o ../${isoname}.iso \ 141 | -v -v \ 142 | -A "FuguIta - OpenBSD-based Live System" \ 143 | -P "Copyright (c) `date +%Y` Yoshihiro Kawamata" \ 144 | -p "Yoshihiro Kawamata, https://fuguita.org/" \ 145 | -V "$isoname" \ 146 | -b cdbr \ 147 | $eficd_opt \ 148 | -c boot.catalog \ 149 | . 150 | --------------------------------------------------------------------------------