1 #!/bin/bash 2 3 # We will tail outputs to file, so we need get correctly errors from pipe 4 5 set -o pipefail 6 7 # 8 # CDDL HEADER START 9 # 10 # The contents of this file are subject to the terms of the 11 # Common Development and Distribution License (the "License"). 12 # You may not use this file except in compliance with the License. 13 # 14 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 15 # or http://www.opensolaris.org/os/licensing. 16 # See the License for the specific language governing permissions 17 # and limitations under the License. 18 # 19 # When distributing Covered Code, include this CDDL HEADER in each 20 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 21 # If applicable, add the following below this CDDL HEADER, with the 22 # fields enclosed by brackets "[]" replaced with your own identifying 23 # information: Portions Copyright [yyyy] [name of copyright owner] 24 # 25 # CDDL HEADER END 26 # 27 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 28 # Use is subject to license terms. 29 30 # Get if we are on x86 or SPARC 31 32 ALTROOT=$1 33 HARDERN=$2 34 35 ISA_INFO=`/sbin/uname -p` 36 37 echo "INFO: We are on platform: $ISA_INFO" 38 39 echo "START: JeOS customization and Fast Fixes" 40 41 # JeOS default Customizations and FastFixes here 42 43 # Load ssh key (hack for now, will be service loading key from instance zpool in future) 44 45 echo "Getting logic to load user specifics ssh authorized keys (Skipped - now SMF service)" 46 47 # Note: We need disable sshd by default !!! 48 49 # Will set them later to now if SSH keys based will work OK 50 51 echo "Disable password login in SSHD" 52 53 gsed -i -e 's/PasswordAuthentication yes/PasswordAuthentication no/g' \ 54 -e 's/PAMAuthenticationViaKBDInt yes/PAMAuthenticationViaKBDInt no/g' \ 55 ${ALTROOT}/etc/ssh/sshd_config 56 57 if [ $ISA_INFO = "sparc" ] ; then 58 echo "No direct drivers Fast Fixes for Ldoms (SPARC), so (skipping)" 59 else 60 61 # Fast fix for ide timetouts in Parallels and some QEMU versions and drivates 62 # This in addtion to DMA disable options in VA GRUB menu 63 64 echo "FastFix [2368]: for some IDE CD-ROM timetous" 65 66 # Bug 2368 - Install from CD "hangs" on Ferrari 5000, CD medium is not selectable 67 # http://defect.opensolaris.org/bz/show_bug.cgi?id=2368 68 69 gsed -i -e 's/timing_flags=0x0/timing_flags=0x1/g' \ 70 ${ALTROOT}/kernel/drv/ata.conf 71 72 # Make a fastfix for dnet driver issues from SXDE B113 (Binary Kernel Compatility) 73 # 6768204 osol_2009.06u2 Updated, P2 driver/dnet dnet interface takes a long 74 # time to resume after plumb/unplumb in Hyper-V virtual machine 75 # http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6768204 76 77 78 echo "FastFix [6768204]: 'dnet' driver timeous (for now from SXDE B113)" 79 80 cp /usr/share/distro_const/virt_assist/fastfixes/SUNWos86r.sxce.b113/archive/kernel/drv/dnet \ 81 ${ALTROOT}/kernel/drv/dnet 82 83 cp /usr/share/distro_const/virt_assist/fastfixes/SUNWos86r.sxce.b113/archive/kernel/drv/amd64/dnet \ 84 ${ALTROOT}/kernel/drv/amd64/dnet 85 fi 86 87 echo "FastFix [4994422]: for time message in virtualizations [4994422]" 88 89 # 4994422 WARNING: Time of Day clock error: reason [Jumped by 0x79]. 90 # http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4994422 91 92 # In virtualizations clocks are often moved in time, so we will disable harmelss TOD waring 93 cat <<EOF >>${ALTROOT}/etc/system 94 set tod_validate_enable=0 95 EOF 96 97 # Copy license file (TBD - finalize license) 98 99 echo "Copy updated license file" 100 101 # For now same lincese for x86 and SPARC 102 # We wil try to use common install base and only support LDoms (SPARC), 103 # so no SPARC specifics packages will be presend (To drives tight to SUN4V) 104 105 if [ $ISA_INFO = "sparc" ] ; then 106 cp /usr/share/virt_assist/install.JeOS/license.media/LICENSE.sparc.JeOS \ 107 ${ALTROOT}/etc/notices/LICENSE 108 cp /usr/share/virt_assist/install.JeOS/license.media/LICENSE.sparc.JeOS \ 109 ${ALTROOT}/etc/notices/LICENSE.JeOS 110 else 111 cp /usr/share/virt_assist/install.JeOS/license.media/LICENSE.i386.JeOS \ 112 ${ALTROOT}/etc/notices/LICENSE 113 cp /usr/share/virt_assist/install.JeOS/license.media/LICENSE.i386.JeOS \ 114 ${ALTROOT}/etc/notices/LICENSE.JeOS 115 fi 116 117 # Setting up default system language to have setup all locale stuff on boot 118 # AI will do this for JeOS 119 120 echo "FASTFIX for LOCALES (Now default LANG=C,LC_ALL=C)" 121 122 # cat <<EOF >>${ALTROOT}/etc/default/init 123 # LANG=en_US.UTF-8 124 # LC_ALL=en_US.UTF-8 125 # EOF 126 127 # Open Source ni driver for ne2000 rtl8029 for Parrallels (or QEMU) (skipped) 128 # Will add it as local IPS package VGURUni (only for 32 bit) to have it in license file 129 130 # This step is skipped, becuase for JeOS user can install driver from Parralles ISO media. 131 132 echo "FASTFIX for ZFS ARCH cache (skiped)" 133 134 # Do we realy need this for JeOS or for final image ? 135 # Modify /etc/system to make ZFS less mem hungry 136 # We target 512MB RAM (ZFS Cache: 65MB 68157440 0x4100000) 137 # $CAT <<EOF >>${ALTROOT}/etc/system 138 # set zfs:zfs_arc_max=0x4100000 139 # set zfs:zfs_vdev_cache_size=0 140 # EOF 141 142 # FastFix for Bug 5394 "OSOL1108 RC2 SUNWbeadm missing file and dependency, can't make Pure CLI" 143 # http://defect.opensolaris.org/bz/show_bug.cgi?id=5394 144 # Wee include in JeOS a SUNWinstall to fix it 145 # but for plain recovery console we will need it 146 147 echo "FastFix [5394]: Make beadm functional (Skipped, included SUNWinstall)" 148 149 # Get IP on boot (Chanlenge in NWAM, because it is runing on backgroud :-( ) 150 151 echo "Adding logic to show IP from NWAM DHCP on console" 152 153 mkdir -p ${ALTROOT}/etc/nwam/ulp/vm-instance 154 155 cp /usr/share/virt_assist/install.JeOS/addons/etc/nwam/ulp/check-conditions \ 156 ${ALTROOT}/etc/nwam/ulp/check-conditions 157 158 chmod 0755 ${ALTROOT}/etc/nwam/ulp/check-conditions 159 160 cp /usr/share/virt_assist/install.JeOS/addons/etc/nwam/ulp/vm-instance/bringup \ 161 ${ALTROOT}/etc/nwam/ulp/vm-instance/bringup 162 163 chmod 0755 ${ALTROOT}/etc/nwam/ulp/vm-instance/bringup 164 165 cp /usr/share/virt_assist/install.JeOS/addons/etc/nwam/ulp/vm-instance/teardown \ 166 ${ALTROOT}/etc/nwam/ulp/vm-instance/teardown 167 168 chmod 0755 ${ALTROOT}/etc/nwam/ulp/vm-instance/teardown 169 170 # Hiding ssh new keys, becaue svc "-c" first configrations don't use deps ??? 171 172 ## gsed -i -e 's/echo Creating/#echo Creating/g' ${ALTROOT}/lib/svc/method/sshd 173 174 # Placholder for /etc/issues , last mepty line is for NWAM IP !!! 175 176 echo "Filling up /etc/issues as first touch informations" 177 178 cp /usr/share/virt_assist/install.JeOS/addons/etc/issue \ 179 ${ALTROOT}/etc/issue 180 181 # Placholder for /issues , last mepty line is for NWAM IP !!! 182 183 echo "Filling up /etc/issues as first touch informations" 184 185 cp /usr/share/virt_assist/install.JeOS/addons/etc/issue \ 186 ${ALTROOT}/etc/issue 187 188 189 # Placeholder for /etc/motd 190 191 echo "Filling up /etc/motd as second touch informations" 192 193 # Add build info and version here (Version will be taken from SC when we integrate) 194 195 . /usr/share/distro_const/virt_assist/.build 196 197 if [ $ISA_INFO = "sparc" ] ; then 198 199 gsed -e "s/#BUILD#/${BUILD}/g" \ 200 /usr/share/virt_assist/install.JeOS/addons/etc/motd.sparc \ 201 >${ALTROOT}/etc/motd 202 203 else 204 205 gsed -e "s/#BUILD#/${BUILD}/g" \ 206 /usr/share/virt_assist/install.JeOS/addons/etc/motd.i386 \ 207 >${ALTROOT}/etc/motd 208 209 fi 210 211 echo "Filling up /export/home/osol/README.txt as second touch informations" 212 213 gsed -e "s/#BUILD#/${BUILD}/g" \ 214 /usr/share/virt_assist/install.JeOS/addons/export/home/osol/README.txt \ 215 >${ALTROOT}/export/home/osol/README.txt 216 217 echo "Filling up /export/home/osol/.links/startpage.html web based informations" 218 219 mkdir ${ALTROOT}/export/home/osol/.links 220 221 cp /usr/share/virt_assist/install.JeOS/addons/export/home/osol/.links/startpage.html \ 222 ${ALTROOT}/export/home/osol/.links/startpage.html 223 224 if [ $ISA_INFO = "sparc" ] ; then 225 echo "No grub menu for SPARC (skipping)" 226 else 227 228 # Generate apropriate GRUB JeOS menus 229 # 6739497 GRUB Splashimage in OpenSolaris causes broken serial console boot 230 # http://defect.opensolaris.org/bz/show_bug.cgi?id=5721#c9 231 232 echo "Generating CLI JeOS oriented GRUB menus" 233 # YES, not altroot here 234 cp /usr/share/virt_assist/install.JeOS/addons/rpool/boot/grub/menu.lst \ 235 /rpool/boot/grub/menu.lst 236 fi 237 238 echo "FastFix [4336]: Createing links for '/usr/has/bin/vi'" 239 240 # FastFix for: 4336 AI image should have link to /usr/has/bin/vi 241 # http://defect.opensolaris.org/bz/show_bug.cgi?id=4336 242 243 ln -s ../has/bin/vi ${ALTROOT}/usr/bin/vim 244 ln -s ../has/bin/vi ${ALTROOT}/usr/bin/vi 245 246 echo "Add some FasFixes defaults to system variables" 247 248 echo "FastFix [2188],[6561]: Increasing a PKG network timeouts and retries" 249 250 # [2188] Client must fail gracefully when network timeout occurs 251 # http://defect.opensolaris.org/bz/show_bug.cgi?id=2188 252 # [6561] Ability to tune number of retries for pkg during net install 253 # http://defect.opensolaris.org/bz/show_bug.cgi?id=6561 254 255 # Put Solaris system VI to path as default and direclty to users 256 cat <<EOF >>${ALTROOT}/etc/profile 257 # PKG_CLIENT_TIMEOUT - (30s) integer value in seconds to wait before timing out (socket timeout) 258 export PKG_CLIENT_TIMEOUT=120 259 # PKG_TIMEOUT_MAX - (4) integer value representing the number of times to retry before failing (retries) 260 export PKG_TIMEOUT_MAX=16 261 EOF 262 263 # Make small scrip to mount ISO images, becuase removal media manager is dependent on GNOME 264 265 echo "Copy ISO mounting scripts" 266 267 cp /usr/share/virt_assist/install.JeOS/fastfix/sbin/mountisos \ 268 ${ALTROOT}/sbin/mountisos 269 270 echo "Preload SMF service for faster boot in ${ALTROOT}" 271 echo " ! 'svccfg' and 'svcadm' errors bellow are harmless and can be ignored !" 272 273 /usr/share/virt_assist/install.JeOS/svcrepo.JeOS ${ALTROOT} \ 274 /usr/share/virt_assist/install.JeOS/jeos_site_smf.xml 275 276 if [ "x$HARDERN" == "x--harden" ] ; then 277 echo "Calling Security Hardening from ISC Kit in ${ALTROOT}" 278 /usr/share/virt_assist/secure.JeOS.isc/run.sh ${ALTROOT} 279 echo "Finished Security Hardening from ISC Kit in ${ALTROOT}" 280 fi 281 282 echo "Add vm-instance smf service - will handle ssh keys, sshd and instance data" 283 echo "Default opensolaris service 'network/ssh' now depend on this service" 284 285 cp /usr/share/virt_assist/install.JeOS/addons/lib/svc/method/vm-instance \ 286 ${ALTROOT}/lib/svc/method/vm-instance 287 288 chmod 0755 ${ALTROOT}/lib/svc/method/vm-instance 289 290 cp /usr/share/virt_assist/install.JeOS/addons/var/svc/manifest/site/vm-instance.xml \ 291 ${ALTROOT}/var/svc/manifest/site/vm-instance.xml 292 293 echo "Updating boot archive in ${ALTROOT} so changed system values are in boot image" 294 bootadm update-archive -R ${ALTROOT} 295 296 # Fix issues to match JeOS needs 297 298 if [ "x$HARDERN" == "x--harden" ] ; then 299 cp /usr/share/virt_assist/install.JeOS/addons/etc/issue.harden \ 300 ${ALTROOT}/etc/issue 301 fi 302 303 # Add free line thre sowe can put message there 304 echo >> ${ALTROOT}/etc/issue 305 306 # Take full FMRI snapshot of installed pkages, so we reproduce it in future 307 # By direct install of by creating of local repository snapshots 308 309 echo "Generating list of install packages for future references" 310 311 pkg -R ${ALTROOT}/ list -s |sort -u >${ALTROOT}/.pkgsnames-JeOS.$ISA_INFO.lst 312 313 pkg -R ${ALTROOT}/ list -Hv | awk '{print $1}'| sed s%\pkg:/%%|sort -u >${ALTROOT}/.pkgsfmris-JeOS.$ISA_INFO.lst 314 315 # pkg size cleanup 316 317 echo "Setting up official OpenSolaris IPS repositories" 318 319 pkg -R ${ALTROOT} set-publisher -P -O http://pkg.opensolaris.org/release/ opensolaris.org 320 pkg -R ${ALTROOT} set-publisher -O http://pkg.opensolaris.org/contrib/ contrib 321 322 echo "Setting up pkg to automaticaly cleanup download cache" 323 pkg -R ${ALTROOT} set-property flush-content-cache-on-success True 324 325 echo "Cleaing iPKG database (Cache)" 326 327 rm -r ${ALTROOT}/var/pkg/download/* >/dev/null 2>&1 328 329 echo "Cleaing iPKG database (Deep [Indexes and Calalogs]), review it ?" 330 rm -r ${ALTROOT}/var/pkg/catalog/* >/dev/null 2>&1 331 rm -r ${ALTROOT}/var/pkg/index/* >/dev/null 2>&1 332 333 echo "FINISH: JeOS customization and Fast Fixes" 334 335 exit 0 336
