␉␉# check for see if there are any boot options in the temporary directory␊ |
␊ |
␉␉cd "${tempDir}"␊ |
␉␉Dirlist=$(find . -type f | grep "@")␊ |
␉␉Dirlist=$(ls | grep "@")␊ |
␊ |
␉␉if [ "${Dirlist}" ]; then␊ |
␊ |
|
␉␉␉echo "set com.apple.Boot.plist variables"␊ |
␉␉␉echo "**********************************"␊ |
␊ |
␉␉␉#bootplist="${destainationDrive}/.Chameleon/Extra/com.apple.Boot.plist"␊ |
␉␉␉bootplist="${tempDir}/Extra/com.apple.Boot.plist"␊ |
␉␉␉echo "DEBUG: bootplist = ${bootplist}"␉␊ |
␊ |
|
␉␉␉␉bootoptionshdextra[2]="<string>${string}</string>"␊ |
␉␉␉␉#echo "DEBUG: bootoptionshdextra 1 = ${bootoptionshdextra[1]}"␊ |
␉␉␉␉#echo "DEBUG: bootoptionshdextra 2= ${bootoptionshdextra[2]}"␊ |
␉␊ |
␉␉␉␉xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )␊ |
␊ |
␉␉␉␉case "${xmlvalue:0:1}" in␊ |
␉␉␉␉␊ |
␉␉␉␉␉y)␉echo "${overide}=y already set in ${bootplist} skipping."␊ |
␉␉␉␉␉␉echo ""␊ |
␉␉␉␉␉␉;;␊ |
␉␉␉␉echo "Attempting to add ${overide}=${string} to ${bootplist}"␊ |
␉ ␉␉␉array=("${bootoptionshdextra[@]}")␊ |
␉␉␉␉searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"␊ |
␉␉␉␉echo ""␊ |
␊ |
␉␉␉␉␉n)␉echo "${overide}=n is set in ${bootplist} leaving."␊ |
␉␉␉␉␉␉echo ""␊ |
␉␉␉␉␉␉;;␊ |
␉␊ |
␉ ␉␉␉␉*)␉echo "Adding ${overide}=${string} to ${bootplist}"␊ |
␉ ␉␉␉␉␉array=("${bootoptionshdextra[@]}")␊ |
␉␉␉␉␉␉searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"␊ |
␉␉␉␉␉␉echo ""␊ |
␉␉␉␉␉␉;;␊ |
␉␉␉␉esac␊ |
␊ |
␉␉␉␉#echo "set owner privileges for ${bootplist}"␊ |
␉␉␉␉chown "${USER}:20" "${bootplist}"␊ |
␉␉␉done␊ |
|
␉␉␊ |
␊ |
␉␉␉echo "==============================================="␊ |
␉␉␉echo "Remove Boot Options Folders"␊ |
␉␉␉echo "***************************"␊ |
␉␉␉echo "Clean up and Remove Boot Option Null Files"␊ |
␉␉␉echo "******************************************"␊ |
␊ |
␉␉␉#Note - Can this be somehow included above and delete the directory after reading it? ␊ |
␊ |
␉␉␉#cd "${3}/.Chameleon/"␊ |
␉␉␉Dirlist=$(find . -type f | grep "@")␊ |
␉␉␉for bootOptionFile in $Dirlist ; do␊ |
␉␉␉␉echo $bootOptionFile␊ |
␉␉␉␉rm -rf $bootOptionFile␊ |
␉␉␉␉rm $bootOptionFile␊ |
␉␉␉done␊ |
␊ |
␉␉␉echo "-----------------------------------------------"␊ |
|
␉␉else␊ |
␉␉␉echo "No boot options in the temporary directory."␊ |
␉␉fi␊ |
␊ |
␉fi␊ |
␊ |
␊ |
␊ |
␊ |
}␊ |
␊ |
getxmlvalue ()␊ |
{␊ |
# 1 xml key␊ |
# 2 xml file␊ |
if [ -f "${2}" ]; then␊ |
␉local value␊ |
␉while read value; do␊ |
␉if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then␊ |
␉␉read value␊ |
␉␉value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"␊ |
␉␉echo "$value"␊ |
␉␉break␊ |
␉fi␊ |
␉done < "${2}"␊ |
fi␊ |
}␊ |
␊ |
searchfilereplaceline ()␊ |
{␊ |
|
␉␉xmltext="${xmltexttemp%%<*}"␊ |
␊ |
␉␉if [ "${replace}" ]; then␊ |
␉␉echo "DEBUG: Replace=${replace}"␊ |
␉␉␉{␊ |
␉␉␉␉echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"␊ |
␉␉␉}␊ |
|
␉␉␉␉arraysize=0␊ |
␉␉␉␉while [ ${arraysize} -lt ${#array[@]} ];␊ |
␉␉␉␉do␊ |
␉␉␉␉␉#echo "DEBUG: ${xmlelementindent}${array[${arraysize}]}"␊ |
␉␉␉␉␉echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"␊ |
␉␉␉␉ let arraysize="${arraysize}+1"␊ |
␉␉␉␉done␊ |
|
␉␉fi␊ |
␊ |
␉␉if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then␊ |
␉␉echo "DEBUG: Delete=${matchlinefound}"␊ |
␉␉␉{␊ |
␉␉␉:␊ |
␉␉␉}␊ |