1#!/bin/mksh 2# $MirOS: src/distrib/baselive/munge_it.sh,v 1.49 2013/11/30 13:45:21 tg Exp $ 3#- 4# Copyright (c) 2006, 2007, 2008, 2013 5# Thorsten “mirabilos” Glaser <tg@mirbsd.de> 6# 7# Provided that these terms and disclaimer and all copyright notices 8# are retained or reproduced in an accompanying document, permission 9# is granted to deal in this work without restriction, including un- 10# limited rights to use, publicly perform, distribute, sell, modify, 11# merge, give away, or sublicence. 12# 13# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 14# the utmost extent permitted by applicable law, neither express nor 15# implied; without malicious intent or gross negligence. In no event 16# may a licensor, author or contributor be held liable for indirect, 17# direct, other damage, loss, or other issues arising in any way out 18# of dealing in the work, even if advised of the possibility of such 19# damage or existence of a defect, except proven that it results out 20# of said person's immediate fault when using the work as intended. 21#- 22# Patch a freshly unpacked MirOS installation into the standard base 23# system generated live CD distribution. 24 25set -ex 26myplace=$(dirname "$(realpath "$0")") 27 28ed -s etc/X11/XF86Config <<-'EOF' 29 /FontPath.*local/s/^/#/ 30 /FontPath.*100dpi.*unscaled/s/^/#/ 31 /FontPath.*Speedo/s/^/#/ 32 /FontPath.*Type1/s/^/#/ 33 /FontPath.*/s/^/#/ 34 /FontPath.*100dpi/s/^/#/ 35 /FontPath.*cyrillic/s/^/#/ 36 /FontPath.*OTF/s/^/#/ 37 wq 38EOF 39ed -s etc/X11/xdm/Xresources <<-'EOMD' 40 /^xlogin.greeting:/s/CLIENTHOST/the MirOS BSD Live CD/ 41 /-100-100-/s//-75-75-/ 42 /^Chooser.label.label:/s/CLIENTHOST/Live-CD/ 43 wq 44EOMD 45cat >>etc/exports <<-'EOMD' 46 / -ro -maproot=root 47EOMD 48ed -s etc/group <<-'EOMD' 49 /^wheel:/s/$/,live/ 50 /^operator:/s/$/,live/ 51 /^wsrc:/s/$/live/ 52 /^staff:/s/$/,live/ 53 /^www:/s/$/live/ 54 /^dialer:/s/$/live/ 55 /^audio:/s/$/live/ 56 /^nobody:/i 57 live:*:32762: 58 . 59 wq 60EOMD 61ed -s etc/inetd.conf <<-'EOMD' 62 %g/^.tftp/s/^.// 63 %g!/tftpboot!s!!/var&! 64 wq 65EOMD 66ed -s etc/master.passwd <<-'EOMD' 67 /^nobody:/i 68 live:$2a$04$NCMhVFfIg3afYRXLCDGjcOPYJxem4lxSLcthQT5AaejUaAAvIWdCW:32762:32762:staff:0:0:MirOS BSD Live CD User:/home/live:/bin/mksh 69 . 70 wq 71EOMD 72ed -s etc/ntpd.conf <<-'EOMD' 73 /^.server /d 74 i 75 server ntp.mirbsd.org 76 . 77 wq 78EOMD 79ed -s etc/rc <<-'EOMD' 80 1i 81 # $MirOS: src/distrib/baselive/munge_it.sh,v 1.49 2013/11/30 13:45:21 tg Exp $ 82 . 83 /early munge point/d 84 i 85 mount -fwo async,noatime /dev/rd0a /dev 86 cat /dev/.rs >/dev/urandom 2>&- 87 # on sparc, use the nvram to provide some additional entropy 88 # also read some stuff from the HDD etc. (doesn't matter if it breaks) 89 ( ( (for d in {w,s,rai,c}:128, f:1, r:1,512; do b=${d#*,}; d=${d%,*};\ 90 dd if=/dev/r${d%:*}d0c count=${d#*:} ${b:+bs=$b of=/dev/urandom}\ 91 ; done; dd if=/var/db/host.random of=/dev/urandom; dmesg; sysctl\ 92 -a; eeprom) 2>&1 | cksum -a cksum -a sha512 -a suma -a tiger -a \ 93 rmd160 -a adler32 -b >/dev/wrandom) &) 94 (cd /dev; ln -s $(sysctl -n kern.root_device) root; rm -f .rs) 95 print \#\\tMirOS BSD Live-CD/DVD/USB/CF/SD/HDD starting up... 96 . 97 /^raidctl.*all/s/^/#/ 98 /^umount/a 99 mount -fwo async,noatime /dev/rd0a /dev >/dev/null 2>&1 100 . 101 /t nonfs/i 102 print -n 'extracting mfs contents...' 103 gzip -dc /stand/fsrw.dat | pax -r -pe 104 print -n ' populating...' 105 sleep 1 106 cp -r etc/skel home/live 107 chown -R 32762:32762 home/live 108 [[ -s /stand/locate.database ]] && \ 109 cp /stand/locate.database /var/db/locate.database 110 wait 111 print ' done' 112 113 . 114 /dmesg.boot/i 115 116 # try to get some entropy from any attached Simtec EntropyKey 117 [[ -x /usr/libexec/ekeyrng ]] && /usr/libexec/ekeyrng 118 # try to get some entropy from the network 119 (ulimit -T 60; exec /usr/bin/ftp -mvo /dev/urandom \ 120 https://call.mirbsd.org/rn.cgi?live"<$(uname -a | sed ' 121 s/%/%25/g 122 s/;/%3b/g 123 s,/,%2f,g 124 s/?/%3f/g 125 s/:/%3a/g 126 s/@/%40/g 127 s/&/%26/g 128 s/=/%3d/g 129 s/+/%2b/g 130 s/\$/%24/g 131 s/,/%2c/g 132 s/ /%20/g 133 ')>,seed=$(dd if=/dev/arandom bs=57 count=1 2>&- | \ 134 b64encode -r - | tr '+=/' '._-')" >/dev/wrandom 2>&1) 135 . 136 /openssl genrsa/s/4096/1024/ 137 wq 138EOMD 139ed -s etc/rc.securelevel <<-'EOMD' 140 /^securelevel/s/1/-1/ 141 wq 142EOMD 143ed -s etc/sysctl.conf <<-'EOMD' 144 /accept_rtadv/s/^.// 145 /^.ddb.console/s/^.// 146 /^.kern.seminfo.semmni/s/^.// 147 /^.kern.seminfo.semmns/s/^.// 148 /^.kern.seminfo.semmnu/s/^.// 149 /^.kern.shminfo.shmall/s/^.// 150 wq 151EOMD 152[[ $MACHINE = i386 ]] && ed -s etc/sysctl.conf <<-'EOMD' 153 /^.machdep.allowaperture/s/^.// 154 /^.machdep.kbdreset/s/^.// 155 /^.kern.emul.linux/s/^.// 156 /^.kern.emul.openbsd/s/^.// 157 wq 158EOMD 159cp etc/ttys.dist etc/ttys 160perl -p -i -e 's/MirOS ftp.1./MirOS LiveCD/' usr/bin/ftp 161ed -s var/cron/tabs/root <<-'EOMD' 162 /anacron/s/^/#/ 163 /daily/s/^/#/ 164 /weekly/s/^/#/ 165 /monthly/s/^/#/ 166 /randshuffle/s/^/#/ 167 /randomnumbers.info/s/^.// 168 /fourmilab.ch/s/^.// 169 /random.org/s/^.// 170 wq 171EOMD 172 173install -c -o root -g staff -m 644 \ 174 $myplace/fstab etc/fstab 175install -c -o root -g staff -m 644 \ 176 $myplace/$MACHINE/rc.conf.local etc/rc.conf.local 177install -c -o root -g staff -m 644 \ 178 $myplace/$MACHINE/rc.netselect etc/rc.netselect 179install -c -o root -g staff -m 644 \ 180 $myplace/rc.netselect.common etc/rc.netselect.common 181install -c -o root -g staff -m 644 \ 182 $myplace/dot.xsession etc/skel/.xsession 183install -c -o root -g bin -m 555 \ 184 $myplace/evilwm-session usr/local/bin/evilwm-session 185 186(cd dev; mksh ./MAKEDEV std rd0a) 187pwd_mkdb -pd $(realpath etc) master.passwd 188( ( dd if=/dev/prandom bs=64 count=7; \ 189 dd if=/dev/arandom bs=64 count=56; \ 190 dd if=/dev/urandom bs=64 count=1; \ 191 ) 2>/dev/wrandom | dd of=var/db/host.random; \ 192 chown 0:0 var/db/host.random; \ 193 chmod 600 var/db/host.random) \ 194 >/dev/wrandom 2>&1 195 196(cd usr/libdata/ldscripts; rm !(*mbsd*)) 197 198# sync with src/distrib/common/listend.i386-big 199(saveIFS=$IFS 200 tail -3 <usr/share/doc/README | grep '^key ' | \ 201 while IFS=" " read keynr keyfile; do 202 IFS=" :" 203 set -A keyno -- $keynr 204 IFS=$saveIFS 205 print -r -- $keyfile >gzsigkey.${keyno[1]} 206done) 207 208(cd usr/X11R6/lib/X11/fonts; rm -rf 100dpi OTF Speedo Type1 cyrillic local \ 209 misc/*-ISO8859-@(1[013456]|[2345789]).* misc/*{KOI8,JISX0201}* \ 210 75dpi/*-ISO8859-@(1[0345]|[2349]).* misc/{fonts.alias,gb,hang,jis,k14}*) 211cp $myplace/misc_fonts.alias usr/X11R6/lib/X11/fonts/misc/fonts.alias 212chown 0:0 usr/X11R6/lib/X11/fonts/misc/fonts.alias 213chmod 444 usr/X11R6/lib/X11/fonts/misc/fonts.alias 214(cd usr/X11R6/lib/X11/fonts/75dpi; mkfontdir) 215(cd usr/X11R6/lib/X11/fonts/misc; mkfontdir) 216(cd usr/X11R6/lib/X11; fc-cache -v .) 217 218mv usr/X11R6/lib/X11/fonts usr/X11R6/lib/fonts 219(cd usr/X11R6/lib/X11; ln -s ../fonts) 220# tmp because of perms 221find etc tmp usr/X11R6/lib/X11 var | sort | \ 222 cpio -oC512 -Hsv4crc -Mset | gzip -n9 >stand/fsrw.dat 223rm -rf usr/X11R6/lib/X11 var sys 224mkdir -p emul usr/X11R6/lib/X11 usr/mpkg usr/ports var 225chown 0:0 emul var 226 227exit 0 228