mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			225 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			225 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|       <pre-scripts config:type="list">
 | |
|         <script>
 | |
|           <filename>foo.sh</filename>
 | |
|           <interpreter>shell</interpreter>
 | |
|           <debug config:type="boolean">false</debug>
 | |
|           <source>
 | |
| 
 | |
| <![CDATA[
 | |
| #!/bin/sh
 | |
| 
 | |
| {
 | |
| export MASTER_IP="#ENV:MASTER_IP#"
 | |
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
 | |
| log_label="xcat.deployment"
 | |
| msgutil_r "$MASTER_IP" "info" "============deployment starting============" "/var/log/xcat/xcat.log" "$log_label"
 | |
| msgutil_r "$MASTER_IP" "info" "Running AutoYaST Pre-Installation script..." "/var/log/xcat/xcat.log" "$log_label"
 | |
| echo "Running AutoYaST Pre-Installation script..."
 | |
| 
 | |
| export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     set -x
 | |
| fi
 | |
| 
 | |
| AWK=`find / -name awk | tail -1`
 | |
| #old awk /mounts/instsys/bin/awk -f
 | |
| if [ ! -e /usr/bin/awk ]; then
 | |
|     ln -s $AWK /usr/bin/awk
 | |
| fi
 | |
| 
 | |
| XCATDPORT=#TABLE:site:key=xcatiport:value#
 | |
| XCATDHOST="#XCATVAR:XCATMASTER#"
 | |
| 
 | |
| (
 | |
| cat << 'EOF'
 | |
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk#
 | |
| EOF
 | |
| ) > /tmp/updateflag
 | |
| 
 | |
| if [ ! -c /dev/vcs ]; then
 | |
| 	mknod /dev/vcs c 7 0
 | |
| fi
 | |
| cat >/tmp/foo.awk <<EOF
 | |
| #!$AWK -f
 | |
| 
 | |
| BEGIN {
 | |
| 	ns = "/inet/tcp/3054/0/0"
 | |
| 
 | |
| 	while(1) {
 | |
| 		ns |& getline
 | |
| 
 | |
| #UNCOMMENTOENABLEDEBUGPORT#		if(\$1 == "sh") { #TODO: ENABLE IF DEBUG
 | |
| #UNCOMMENTOENABLEDEBUGPORT#			sub(/^sh +/,"",\$0)
 | |
| #UNCOMMENTOENABLEDEBUGPORT#			output = \$0
 | |
| #UNCOMMENTOENABLEDEBUGPORT#			while((output | getline) > 0)
 | |
| #UNCOMMENTOENABLEDEBUGPORT#				print \$0 |& ns
 | |
| #UNCOMMENTOENABLEDEBUGPORT#			print "EOO" |& ns
 | |
| #UNCOMMENTOENABLEDEBUGPORT#			close(output)
 | |
| #UNCOMMENTOENABLEDEBUGPORT#		}
 | |
| 
 | |
| 		if(\$1 == "screendump") {
 | |
| 			output = "chvt " \$2 ";cat /dev/vcs"
 | |
| 			while((output | getline) > 0)
 | |
| 				print \$0 |& ns
 | |
| 			close(output)
 | |
| 		}
 | |
| 
 | |
| 		if(\$1 == "stat") {
 | |
| 		    if( system( "[ -f /mnt/var/log/YaST2/y2logRPM ]" )  == 0 ) {		
 | |
| 			while((getline < "/mnt/var/log/YaST2/y2logRPM") > 0) {
 | |
| 				line = \$0
 | |
| 			}
 | |
| 			close("/mnt/var/log/YaST2/y2logRPM")
 | |
| 
 | |
| 			if(line ~ /\.rpm /) {
 | |
| 				sub(/\.[^\.]+\.rpm .*$/,"",line)
 | |
| 				sub(/^.* /,"",line)
 | |
| 			}
 | |
| 			else {
 | |
| 				line = "prep"
 | |
| 			}
 | |
| 
 | |
| 			print ("installing " line) |& ns
 | |
| 		    }
 | |
|          	    else {
 | |
| 			# The format of /var/log/zypp/history is documented at
 | |
| 			#     http://en.opensuse.org/Libzypp/Package_History
 | |
| 
 | |
| 			lastrpm = "prep"
 | |
| 
 | |
| 			oldFS = FS
 | |
| 			FS="|"
 | |
| 
 | |
| 			while((getline < "/mnt/var/log/zypp/history") > 0) {
 | |
| 				if (\$0 !~ /#/ && \$2 == "install") {
 | |
| 					lastrpm = (\$3 "-" \$4)
 | |
| 				}
 | |
| 			}
 | |
| 			close("/mnt/var/log/zypp/history")
 | |
| 
 | |
| 			FS = oldFS
 | |
| 
 | |
| 			print ("installing " lastrpm) |& ns
 | |
|                    }
 | |
|                }
 | |
| 
 | |
| 	       close(ns)
 | |
| 	}
 | |
| }
 | |
| EOF
 | |
| 
 | |
| chmod 755 /tmp/foo.awk
 | |
| chmod 755 /tmp/updateflag
 | |
| 
 | |
| /tmp/updateflag $XCATDHOST $XCATDPORT "installmonitor" &
 | |
| 
 | |
| NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value#
 | |
| 
 | |
| if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a   "$NODESTATUS" != "N"  -a  "$NODESTATUS" != "n" ]; then
 | |
|    /tmp/updateflag $XCATDHOST $XCATDPORT "installstatus installing" &
 | |
| fi
 | |
| 
 | |
| /tmp/foo.awk >/tmp/foo.log 2>&1 &
 | |
| 
 | |
| base64decode()
 | |
| {
 | |
|     h0="0";  h1="1";  h2="2";  h3="3";  h4="4";  h5="5";  h6="6";  h7="7";
 | |
|     h8="8";  h9="9"; h10="A"; h11="B"; h12="C"; h13="D"; h14="E"; h15="F";
 | |
| 
 | |
|     while :
 | |
|     do
 | |
|         i=0
 | |
|         while [ "$i" -lt 4 ]
 | |
|         do
 | |
|             read -n 1 c || return
 | |
| 
 | |
|             case "${c}" in
 | |
|             "A") d=0  ;; "B") d=1  ;; "C") d=2  ;; "D") d=3  ;;
 | |
|             "E") d=4  ;; "F") d=5  ;; "G") d=6  ;; "H") d=7  ;;
 | |
|             "I") d=8  ;; "J") d=9  ;; "K") d=10 ;; "L") d=11 ;;
 | |
|             "M") d=12 ;; "N") d=13 ;; "O") d=14 ;; "P") d=15 ;;
 | |
|             "Q") d=16 ;; "R") d=17 ;; "S") d=18 ;; "T") d=19 ;;
 | |
|             "U") d=20 ;; "V") d=21 ;; "W") d=22 ;; "X") d=23 ;;
 | |
|             "Y") d=24 ;; "Z") d=25 ;; "a") d=26 ;; "b") d=27 ;;
 | |
|             "c") d=28 ;; "d") d=29 ;; "e") d=30 ;; "f") d=31 ;;
 | |
|             "g") d=32 ;; "h") d=33 ;; "i") d=34 ;; "j") d=35 ;;
 | |
|             "k") d=36 ;; "l") d=37 ;; "m") d=38 ;; "n") d=39 ;;
 | |
|             "o") d=40 ;; "p") d=41 ;; "q") d=42 ;; "r") d=43 ;;
 | |
|             "s") d=44 ;; "t") d=45 ;; "u") d=46 ;; "v") d=47 ;;
 | |
|             "w") d=48 ;; "x") d=49 ;; "y") d=50 ;; "z") d=51 ;;
 | |
|             "0") d=52 ;; "1") d=53 ;; "2") d=54 ;; "3") d=55 ;;
 | |
|             "4") d=56 ;; "5") d=57 ;; "6") d=58 ;; "7") d=59 ;;
 | |
|             "8") d=60 ;; "9") d=61 ;; "+") d=62 ;; "/") d=63 ;;
 | |
|             "=") d=0  ;;
 | |
|             *) continue ;;
 | |
|             esac
 | |
| 
 | |
|             eval "a${i}=${c}"
 | |
|             eval "b${i}=${d}"
 | |
| 
 | |
|             i=$(( i + 1 ))
 | |
|         done
 | |
| 
 | |
|         o0=$(( ((b0 << 2) | (b1 >> 4)) & 0xff ))
 | |
|         o1=$(( ((b1 << 4) | (b2 >> 2)) & 0xff ))
 | |
|         o2=$(( ((b2 << 6) | b3) & 0xff ))
 | |
| 
 | |
|         [ "${a2}" == "=" ] &&
 | |
|             eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
 | |
|                 ))}\"" &&
 | |
|             return
 | |
|         [ "${a3}" == "=" ] &&
 | |
|             eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
 | |
|                 ))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16
 | |
|                 ))}\"" &&
 | |
|             return
 | |
|         eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
 | |
|             ))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16
 | |
|             ))}\\x\${h$(( o2 / 16 ))}\${h$(( o2 % 16 ))}\""
 | |
|     done
 | |
| }
 | |
| 
 | |
| shopt -s nullglob
 | |
| msgutil_r "$MASTER_IP" "info" "Detecting install disk..." "/var/log/xcat/xcat.log" "$log_label"
 | |
| #
 | |
| # The getinstdisk script is common for RHEL/SLES/PowerKVM/Ubuntu.
 | |
| # It will attempt to select the install disk and write the selection to /tmp/xcat.install_disk
 | |
| #
 | |
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/getinstdisk#
 | |
| if [ -e "/tmp/xcat.install_disk" ]; then
 | |
|     instdisk=`cat /tmp/xcat.install_disk`
 | |
| fi
 | |
| 
 | |
| msgutil_r "$MASTER_IP" "info" "Found $instdisk, generate partition file..." "/var/log/xcat/xcat.log" "$log_label"
 | |
| if [ -d /sys/firmware/efi ]; then
 | |
| 	sed -e 's!<device>XCATPARTITIONHOOK</device>!<device>'$instdisk'</device><partitions config:type="list"><partition><filesystem config:type="symbol">vfat</filesystem><mount>/boot/efi</mount><size>128mb</size></partition><partition><mount>swap</mount><size>auto</size></partition><partition><mount>/</mount><size>auto</size></partition></partitions>!' /tmp/profile/autoinst.xml > /tmp/profile/modified.xml
 | |
| else
 | |
| 	sed -e 's!<device>XCATPARTITIONHOOK</device>!<device>'$instdisk'</device><partitions config:type="list"><partition><filesystem  config:type="symbol">xfs</filesystem><mount>/</mount><size>auto</size></partition><partition><mount>swap</mount><size>auto</size></partition></partitions>!' /tmp/profile/autoinst.xml > /tmp/profile/modified.xml
 | |
| fi
 | |
| #XCA_PARTITION_SCRIPT#
 | |
| #add the following part for replace the partition definition in /tmp/profile/autoinst.xml
 | |
| if [ -r "/tmp/partitionfile" ]; then
 | |
|     while read line
 | |
|     do
 | |
|         con="${con}${line}"
 | |
|     done < /tmp/partitionfile
 | |
|     con=${con//>\s+</><}
 | |
|     con=${con// /xcattempspace}
 | |
|     sed -e '/<drive>/{N;N;s!.*!'$con'!}' /tmp/profile/autoinst.xml > /tmp/profile/modified1.xml
 | |
|     sed -e 's!xcattempspace! !g' /tmp/profile/modified1.xml > /tmp/profile/modified.xml
 | |
| fi
 | |
| msgutil_r "$MASTER_IP" "info" "Generate the repository for the installation" "/var/log/xcat/xcat.log" "$log_label"
 | |
| export nextserver=`cat /proc/cmdline | grep http | awk -F'autoyast=http://' {'print \$2'} | awk -F':' {'print \$1'}`
 | |
| cp /tmp/profile/modified.xml /tmp/profile/modified1.xml
 | |
| sed -e 's!<software>!<add-on><add_on_products config:type="list">#INSTALL_SOURCES_IN_PRE#</add_on_products></add-on><software>!'  /tmp/profile/modified1.xml > /tmp/profile/modified.xml
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     set +x
 | |
| fi
 | |
| } >>/tmp/pre-install.log 2>&1
 | |
| ]]>
 | |
| 
 | |
|           </source>
 | |
|         </script>
 | |
|       </pre-scripts>
 |