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 if [ "x$1" == "x" ]; then 31 echo "This VA module will install OpenSolaris 200906 JeOS Prototype with customizations" 32 echo "" 33 echo "JeOS-install.sh [-debug] {--publicrepo|--custom|--localrepo} {--[no]harden}" 34 echo " -debug - activate debug output mainly for AI Clinet amd related frameworks" 35 echo " --publicrepo - install JeOS from network based public repo pkg.opensolaris.org" 36 echo " --custom - install custom JeOS, will see what level of cutomizations we can get" 37 echo " --localrepo - install JeOS from local IPS repo free as jeos-ai-vm-proto cluster" 38 echo " local repo must be in atached as disk with zpool 'localrepos'" 39 echo " zpool 'localrepos' is prepared with module 'repo.clone.JeOS'" 40 echo " --harden/--noharden - to run/don't run a 'secure.JeOS.isc' in JeOS postinstall" 41 exit 1 42 fi 43 44 echo "For this module you need VM configured with: VCPU=1 Memory=1024MB VDISK=8GB NET" 45 echo "Mininum Memory is 512MB, but in this case JeOS installation can use SWAP on DISK" 46 echo "" 47 /usr/share/virt_assist/common.lib/showvmconfig 48 49 sleep 10 50 51 echo "START: JeOS customization and Fast Fixes" 52 53 ISA_INFO=`/sbin/uname -p` 54 55 echo "INFO: We are on platform: $ISA_INFO" 56 57 # ToDo: 58 # - Check /.nwamhasip for remote installations to be sure then we allready have network ??? 59 # 60 61 # AI Engine exit codes 62 # success - do not reboot 63 AI_ENGINE_EXIT_SUCCESS=0 64 # success - auto reboot 65 AI_ENGINE_EXIT_REBOOT=64 66 # failure 67 AI_ENGINE_EXIT_FAILURE=1 68 # invalid or incompatible manifest specified 69 AI_ENGINE_EXIT_FAILURE_INVALID_MANIFEST=2 70 # Error during calling finish ICT phase (Install Competiton Tasks) 71 AI_ENGINE_EXIT_FINISHERROR=8 72 73 function pause(){ 74 read -n 1 -p ���$*��� 75 } 76 77 echo "Importnat: You need to bee 'root' othervice installation will hang at this step" 78 79 rm /.livecd >/dev/null 2>&1 80 touch /.autoinstall 81 82 cd /tmp 83 84 /usr/bin/cp /usr/share/auto_install/ai_manifest.rng /tmp/ 85 /usr/bin/cp /usr/share/auto_install/ai_manifest.defval.xml /tmp/ 86 87 if [ "$1" == "-debug" ] 88 then 89 shift 90 export BE_PRINT_ERR=true 91 export LS_DBG_LVL=4 92 debug_install="-v" 93 else 94 debug_install="" 95 fi 96 97 install_mode="" 98 99 echo "Mounting all workarounds in install framework here" 100 101 # Skip browser home page which makes error 102 # See more in: 103 # /usr/share/virt_assist/install.JeOS/fastfix/usr/lib/python2.4/vendor-packages/osol_install/ 104 # 105 ## RFE: Install-finish ICT_FIX_BROWSER_HOME_PAGE_FAILED must be soft 106 ## http://defect.opensolaris.org/bz/show_bug.cgi?id=5558 107 ## We preffer to patch /sbin/, taher to use patch to more complex and RO ict.py 108 109 110 ## if [ "$debug_install" == "-v" ]; then 111 ## echo "FastFix [5558] Checking install-finish ICT before overlay" 112 ## ls -l /usr/lib/python2.4/vendor-packages/osol_install/ict.py | grep ict.py | awk '{print $5}' 113 ## md5sum /usr/lib/python2.4/vendor-packages/osol_install/ict.py 114 ## ls -l /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc | grep ict.pyc | awk '{print $5}' 115 ## md5sum /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc 116 ## fi 117 118 echo "FastFix [5558]: Activating install-finish ICT Browser" 119 120 gsed -i -e 's/\tsa.append(icto.fix_browser_home_page())/\t#sa.append(icto.fix_browser_home_page())/g' /sbin/install-finish 121 122 ## mount -F lofs -O \ 123 ## /usr/share/virt_assist/install.JeOS/fastfix/usr/lib/python2.4/vendor-packages/osol_install/ict.py \ 124 ## /usr/lib/python2.4/vendor-packages/osol_install/ict.py 125 126 mount -F lofs -O \ 127 /usr/share/virt_assist/install.JeOS/fastfix/usr/lib/python2.4/vendor-packages/osol_install/ict.pyc \ 128 /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc 129 130 ## if [ "$debug_install" == "-v" ]; then 131 ## echo "FastFix [5558]: Checking install-finish ICT after overlay" 132 ## ls -l /usr/lib/python2.4/vendor-packages/osol_install/ict.py | grep ict.py | awk '{print $5}' 133 ## md5sum /usr/lib/python2.4/vendor-packages/osol_install/ict.py 134 ## ls -l /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc | grep ict.pyc | awk '{print $5}' 135 ## md5sum /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc 136 ## fi 137 138 # Overlay for main install lib to have consistent installations on relatively low resources 139 # See more in: 140 # /usr/share/virt_assist/install.JeOS/fastfix/usr/snadm/lib 141 # 142 ## Automatic installer must create consitent VM configs with low resource usages 143 ## http://defect.opensolaris.org/bz/show_bug.cgi?id=9076 144 145 if [ "$debug_install" == "-v" ]; then 146 echo "FastFix [9076]: Checking liborchestrator before overlay" 147 ls -l /usr/snadm/lib/liborchestrator.so.1 | grep liborchestrator | awk '{print $5}' 148 ldd /usr/snadm/lib/liborchestrator.so.1 | wc -l 149 md5sum /usr/snadm/lib/liborchestrator.so.1 150 fi 151 152 echo "FastFix [9076]: Activating liborchestrator overlay" 153 154 if [ $ISA_INFO == "sparc" ]; then 155 mount -F lofs -O /usr/share/virt_assist/install.JeOS/fastfix/usr/snadm/lib/liborchestrator.sparc.so.1 \ 156 /usr/snadm/lib/liborchestrator.so.1 157 else 158 mount -F lofs -O /usr/share/virt_assist/install.JeOS/fastfix/usr/snadm/lib/liborchestrator.i386.so.1 \ 159 /usr/snadm/lib/liborchestrator.so.1 160 fi 161 162 if [ "$debug_install" == "-v" ]; then 163 164 echo "FastFix [9076]: Checking liborchestrator after overlay" 165 ls -l /usr/snadm/lib/liborchestrator.so.1 | grep liborchestrator | awk '{print $5}' 166 ldd /usr/snadm/lib/liborchestrator.so.1 | wc -l 167 md5sum /usr/snadm/lib/liborchestrator.so.1 168 fi 169 170 echo "OK, now lets do real AI Clinet install work" 171 172 if [ "$1" == "--custom" ]; then 173 if [ -f /tmp/JeOS-ai-vm-custom.xml ] ; then 174 cp /tmp/JeOS-ai-vm-custom.xml /tmp/ai_combined_manifest.xml 175 install_mode="custom" 176 else 177 echo "CUSTOM Mode: Can't find custom AI XML file in /tmp/JeOS-ai-vm-custom.xml" 178 exit 1 179 fi 180 fi 181 182 if [ "$1" == "--publicrepo" ]; then 183 # JeOS.arch.xml is for internet based instllation only 184 if [ $ISA_INFO = "sparc" ] ; then 185 cp /usr/share/virt_assist/install.JeOS/JeOS-ai-vm.sparc.xml /tmp/ai_combined_manifest.xml 186 else 187 cp /usr/share/virt_assist/install.JeOS/JeOS-ai-vm.i386.xml /tmp/ai_combined_manifest.xml 188 fi 189 install_mode="publicrepo" 190 fi 191 192 # JeOS-lr.xml is for Local Repo freeze instllation only (Simple overwrite) 193 194 if [ "$1" == "--localrepo" ]; then 195 # Starting local IPS REPO freeze 196 /usr/share/virt_assist/repo.clone.JeOS/repo-start.sh 197 198 # Copying AI manifest with 'jeos-proto' cluster (same for foth arch (i386 and SPARC) 199 if [ $ISA_INFO = "sparc" ] ; then 200 cp /usr/share/virt_assist/install.JeOS/JeOS-ai-vm-lr.sparc.xml /tmp/ai_combined_manifest.xml 201 else 202 cp /usr/share/virt_assist/install.JeOS/JeOS-ai-vm-lr.i386.xml /tmp/ai_combined_manifest.xml 203 fi 204 install_mode="localrepo" 205 fi 206 207 if [ "$install_mode" == "" ]; then 208 echo "Wrong install mode, run script wihout params to see valid install modes" 209 exit 1 210 fi 211 212 # Workaround for AI finalizer, create a fake logs 213 touch /tmp/ai_sd_log 214 215 /usr/bin/auto-install $debug_install -p /tmp/ai_combined_manifest.xml 2>&1 | tee /var/svc/log/application-auto-installer:default.log 216 217 # Check error levels, get possible exit levels from SMF install service strip 218 219 ret=$? 220 221 # Process exit code returned from AI engine 222 223 echo "AI (Auto Installer) PiPe report exit code: $ret, Analyzing it:" 224 225 case $ret in 226 # 227 # Automated Installer finished successfully. Pass the control 228 # to the user 229 # 230 ${AI_ENGINE_EXIT_SUCCESS}) 231 echo "OK: Automated Installation finished successfully" 232 echo "Now will be executed post config phase" 233 echo "Please refer to /tmp/install_log file for details" 234 235 echo "After reboot it will be located at " \ 236 "/var/sadm/system/logs/install_log" 237 sleep 5 238 ;; 239 240 # 241 # Automated Installer finished successfully. 242 # Automated reboot was enabled in AI manifest, reboot now. 243 # 244 ${AI_ENGINE_EXIT_REBOOT}) 245 echo "OK: Automated Installation finished successfuly" 246 echo "Automated reboot enabled, but is ignored. \n System will continue with post configs" 247 sleep 5 248 ;; 249 250 # 251 # Invalid or incompatible AI configuration manifest specified 252 # 253 ${AI_ENGINE_EXIT_FAILURE_INVALID_MANIFEST}) 254 echo "Reason: Invalid or incompatible manifest provided" 255 echo "Please refer to /var/svc/log/application-auto-installer:default.log file for details" 256 257 exit $AI_ENGINE_EXIT_FAILURE_INVALID_MANIFEST 258 259 ;; 260 261 # 262 # Automated installation failed. 263 # 264 ${AI_ENGINE_EXIT_FAILURE}) 265 echo "Reason: Automated Installation failed" 266 echo "Please refer to /tmp/install_log file for details" 267 268 pause 'Press any key to continue with post config or CTRL-C to stop NOW..' 269 ;; 270 271 ${AI_ENGINE_EXIT_FINISHERROR}) 272 echo "FINISH ERROR: Automated Installation failed on finish ICT phase (Install Competiton Tasks)" 273 echo "Please refer to /tmp/install_log file for details" 274 275 pause 'Press any key to continue with post config or CTRL-C to stop NOW..' 276 ;; 277 278 # 279 # Automated installation failed with unknown exit code 280 # 281 *) 282 echo "Other: Automated Installation failed for unkown reason" 283 echo "Unknown exit code $ret returned" 284 echo "Please refer to /tmp/install_log file for details" 285 echo "Please refer to /var/svc/log/application-auto-installer:default.log file for details" 286 287 pause 'Press any key to continue with post config or CTRL-C to stop NOW..' 288 289 ;; 290 esac 291 292 # Mount back BE sou we can customize installation 293 294 # Some cleaing on zpool rpool 295 296 echo "Some cleaning on zpool rpool first" 297 298 zpool set listsnapshots=on rpool 299 zfs destroy rpool/ROOT/opensolaris@install 300 301 302 # Fully mount BE environment first 303 304 echo "Now will fully mount install environment" 305 306 export ALTROOT=/a 307 308 echo >/tmp/config_log 309 310 /usr/share/virt_assist/common.lib/mount-altroot ${ALTROOT} rpool opensolaris osol 2>&1 | tee -a /tmp/config_log 311 312 # Call JeOS default Configuratinos and FastFixes here 313 314 /usr/share/virt_assist/install.JeOS/JeOS-postconfig.sh ${ALTROOT} $2 2>&1 | tee -a /tmp/config_log 315 316 # Add call for custom post install script HERE 317 318 echo "Custom config Starts" 319 320 if [ "$1" == "--custom" ]; then 321 /tmp/JeOS-customconfig.sh ${ALTROOT} $1 $2 2>&1 | tee -a /tmp/config_log 322 fi 323 324 echo "Custom config Ends" 325 326 # Check error levels here 327 328 # Fully correctly unmount BE environment 329 330 echo "Now will fully umount install environment" 331 332 /usr/share/virt_assist/common.lib/umount-altroot ${ALTROOT} rpool opensolaris osol 2>&1 | tee -a /tmp/config_log 333 334 echo "Umounting all workarounds in install framework here" 335 336 umount /usr/snadm/lib/liborchestrator.so.1 337 ## umount /usr/lib/python2.4/vendor-packages/osol_install/ict.py 338 ## umount /usr/lib/python2.4/vendor-packages/osol_install/ict.pyc 339 340 echo "Please refer to AI install logs /tmp/install_log for details" 341 echo "Please refer to JeOS config logs /tmp/config_log for details" 342 echo "After reboot AI log will be located at /var/sadm/system/logs/install_log" 343 echo "" 344 echo "Finished: Instalation of OpenSolaris 200906 JeOS $ISA_INFO Prototype is complete" 345 346 exit 0 347
