@@ -7,8 +7,11 @@ hive_dir="${mount_dir}/Windows/System32/config/SYSTEM"
77old_guid_file=" ${mount_dir} /migration_manager_old_guids"
88nics_file=" ${mount_dir} /migration_manager_nics"
99
10+ echo " Setting up first-boot network reassignment script"
11+
1012# Just exit if no MACs provided.
1113if [ 0 = ${# } ]; then
14+ echo " No MACs supplied, exiting"
1215 exit 0
1316fi
1417
2124
2225control_set=" $( printf " ControlSet%03d" " ${control_set_num} " ) "
2326
27+ echo " Using control set ${control_set} "
28+
2429# Record each mapping of MAC to InstanceGUID because we can't tell which NIC is which after booting. (And also reading networksetup2 requires elevated privileges).
2530# shellcheck disable=1003
2631hivexregedit --export --prefix ' hklm\system' " ${hive_dir} " " ${control_set} \control\networksetup2\interfaces" --max-depth 3 \
@@ -32,18 +37,22 @@ hivexregedit --export --prefix 'hklm\system' "${hive_dir}" "${control_set}\contr
3237
3338# If we can't find any MACs, then exit.
3439if [ " $( wc -l /tmp/macs_to_guids) " = 0 ]; then
40+ echo " No GUID records found, exiting"
3541 exit 0
3642fi
3743
3844# Remove the state files in case they exist.
3945rm -rf " ${old_guid_file} " " ${nics_file} "
4046
4147for mac in " ${@ } " ; do
48+ echo " Checking mac ${mac} "
49+
4250 # Grab the previous GUID for this MAC.
4351 mac=" $( printf " %s" " ${mac} " | tr ' [:upper:]' ' [:lower:]' ) "
4452 mapping=" $( grep " ^${mac} " -B1 --no-group-separator /tmp/macs_to_guids | head -2) "
4553
4654 if [ -z " ${mapping} " ] ; then
55+ echo " Mac ${mac} not found in GUID mappings"
4756 continue
4857 fi
4958
@@ -52,9 +61,12 @@ for mac in "${@}" ; do
5261 mac=" $( printf " %s" " ${mac} " | tr ' [:lower:]' ' [:upper:]' | sed -e ' s/:/-/g' ) "
5362
5463 if [ -z " ${old_guid} " ] || [ -z " ${mac} " ]; then
64+ echo " Unexpected GUID mapping format: ${mapping} "
5565 exit 1
5666 fi
5767
68+ echo " MAC: ${mac} GUID: ${old_guid} "
69+
5870 echo " ${old_guid} " >> " ${old_guid_file} "
5971 echo " ${mac} " >> " ${nics_file} "
6072done
0 commit comments