# set temporary directory␊ |
chamTemp="$dest_vol/usr/local/chamTemp"␊ |
␊ |
# Check for temporary directory/Extra folder.␊ |
#if [ ! -d "$chamTemp"/Extra ]; then␊ |
#␉mkdir "$chamTemp"/Extra␊ |
#fi␊ |
# Check for stopped installation due to Chameleon␊ |
# already existing on the same disk.␊ |
if [ ! -f "$dest_vol"/.ChameleonExists ]; then␊ |
␊ |
# ---------------------------------------------␊ |
# Add any installed modules to the Install Log␊ |
# ---------------------------------------------␊ |
if [ -e "${chamTemp}"/Extra/modules ]; then␊ |
␉ls "${chamTemp}"/Extra/modules | while read FILE␊ |
␉do␊ |
␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"␊ |
␉done␊ |
fi␊ |
# ---------------------------------------------␊ |
# Add any installed modules to the Install Log␊ |
# ---------------------------------------------␊ |
if [ -e "${chamTemp}"/Extra/modules ]; then␊ |
ls "${chamTemp}"/Extra/modules | while read FILE␊ |
do␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"␊ |
done␊ |
fi␊ |
␉␉␉␊ |
# ---------------------------------------------␊ |
# Add any installed themes to the Install Log␊ |
# ---------------------------------------------␊ |
if [ -e "${chamTemp}"/Extra/Themes ]; then␊ |
␉ls "${chamTemp}"/Extra/Themes | while read FILE␊ |
␉do␊ |
␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"␊ |
␉done␊ |
fi␊ |
# ---------------------------------------------␊ |
# Add any installed themes to the Install Log␊ |
# ---------------------------------------------␊ |
if [ -e "${chamTemp}"/Extra/Themes ]; then␊ |
ls "${chamTemp}"/Extra/Themes | while read FILE␊ |
do␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"␊ |
done␊ |
fi␊ |
␊ |
# ---------------------------------------------␊ |
# Build org.chameleon.Boot.plist␊ |
# ---------------------------------------------␊ |
# All options selected are now dummy files with␊ |
# the filename of the option and value residing␊ |
# in /usr/local/chamTemp/options/␊ |
# for example. Boot Banner=Yes␊ |
# ---------------------------------------------␊ |
# Build org.chameleon.Boot.plist␊ |
# ---------------------------------------------␊ |
# All options selected are now dummy files with␊ |
# the filename of the option and value residing␊ |
# in /usr/local/chamTemp/options/␊ |
# for example. Boot Banner=Yes␊ |
␊ |
# Are there any options to build?␊ |
if [ "$(ls -A ${chamTemp}/options )" ]; then␊ |
# Are there any options to build?␊ |
if [ "$(ls -A ${chamTemp}/options )" ]; then␊ |
␊ |
␉# Check for temporary directory/Extra folder.␊ |
␉if [ ! -d "$chamTemp"/Extra ]; then␊ |
␉␉mkdir "$chamTemp"/Extra␊ |
␉fi␊ |
# Check for temporary directory/Extra folder.␊ |
if [ ! -d "$chamTemp"/Extra ]; then␊ |
mkdir "$chamTemp"/Extra␊ |
fi␊ |
␊ |
␉# Create template for org.chameleon.Boot.plist"␊ |
␉tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist␊ |
␉cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"␊ |
# Create template for org.chameleon.Boot.plist"␊ |
tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist␊ |
cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"␊ |
␊ |
␉# Read list of all boot options the user added.␊ |
␉arrayCount=0␊ |
␉kernelFlagCount=0␊ |
␉while read FILE␊ |
␉do␊ |
␉␉options[arrayCount]="${FILE##*/}"␊ |
# Read list of all boot options the user added.␊ |
arrayCount=0␊ |
kernelFlagCount=0␊ |
while read FILE␊ |
do␊ |
options[arrayCount]="${FILE##*/}"␊ |
␊ |
␉␉# Check keyRead for 'KF' at beginning to␊ |
␉␉# indicate that should be a kernel flag␊ |
␉␉if [ ${options[arrayCount]:0:2} = "KF" ];then␊ |
␉␉␉# plistbuddy only add's if the key doesn't already exist.␊ |
|
␉␉␉# same time once when we reach the end of the options list.␉␊ |
␉␉␉kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"␊ |
␉␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"␊ |
␉␉␉(( kernelFlagCount++ ))␉␊ |
␉␉else␊ |
␉␉␉keyRead="${options[$arrayCount]%=*}"␊ |
␉␉␉value="${options[$arrayCount]#*=}"␊ |
␉␉␉# escape any spaces␊ |
␉␉␉keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )␊ |
␉␉␉if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "USE" ]; then␊ |
␉␉␉␉sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"␊ |
␉␉␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"␊ |
␉␉␉fi␊ |
␉␉fi␉␊ |
␉␉(( arrayCount++ ))␊ |
␉done < <(ls "${chamTemp}"/options )␊ |
# Check keyRead for 'KF' at beginning to␊ |
# indicate that should be a kernel flag␊ |
if [ ${options[arrayCount]:0:2} = "KF" ];then␊ |
# plistbuddy only add's if the key doesn't already exist.␊ |
# So let's store any kernelflags and add them all at the␊ |
# same time once when we reach the end of the options list.␉␊ |
kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"␊ |
(( kernelFlagCount++ ))␉␊ |
else␊ |
keyRead="${options[$arrayCount]%=*}"␊ |
value="${options[$arrayCount]#*=}"␊ |
# escape any spaces␊ |
keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )␊ |
if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "USE" ]; then␊ |
sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"␊ |
fi␊ |
fi␉␊ |
(( arrayCount++ ))␊ |
done < <(ls "${chamTemp}"/options )␊ |
␊ |
␉if [ $kernelFlagCount -gt 0 ]; then␊ |
␉␉# Add kernel flags␊ |
␉␉for (( i=0 ; i < $kernelFlagCount ; i++ ))␊ |
␉␉do␉␊ |
␉␉␉# Add any kernel flags together in to one string.␊ |
␉␉␉kernelFlagString="${kernelFlagString} ${kernelflag[i]}"␊ |
␉␉done␊ |
␉␉sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"␊ |
␉␉if [ ${returnValue}=1 ]; then # key already exists.␊ |
␉␉␉sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"␊ |
␉␉␉sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"␊ |
␉␉fi␊ |
␉fi␉␊ |
fi␊ |
if [ $kernelFlagCount -gt 0 ]; then␊ |
# Add kernel flags␊ |
for (( i=0 ; i < $kernelFlagCount ; i++ ))␊ |
do␉␊ |
# Add any kernel flags together in to one string.␊ |
kernelFlagString="${kernelFlagString} ${kernelflag[i]}"␊ |
done␊ |
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"␊ |
if [ ${returnValue}=1 ]; then # key already exists.␊ |
sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"␊ |
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"␊ |
fi␊ |
fi␉␊ |
fi␊ |
␊ |
# ---------------------------------------------␊ |
# Copy temp Extra folder to target destination␊ |
# ---------------------------------------------␊ |
# If we've made a temporary Extra folder to use then␊ |
# check for an existing /Extra folder. If found, back it up␊ |
# before copying the temporary Extra folder to destination.␊ |
# Extra folder now resides in /usr/local/chamTemp/␊ |
# Copy /usr/local/chamTemp/Extra to correct location.␊ |
# ---------------------------------------------␊ |
# Copy temp Extra folder to target destination␊ |
# ---------------------------------------------␊ |
# If we've made a temporary Extra folder to use then␊ |
# check for an existing /Extra folder. If found, back it up␊ |
# before copying the temporary Extra folder to destination.␊ |
# Extra folder now resides in /usr/local/chamTemp/␊ |
# Copy /usr/local/chamTemp/Extra to correct location.␊ |
␊ |
if [ -d "$chamTemp"/Extra ]; then␊ |
if [ -d "$chamTemp"/Extra ]; then␊ |
␊ |
␉if [ ! -f "$dest_vol"/.ChameleonEFI ]; then␊ |
␉␉# The Standard install option chosen␊ |
if [ ! -f "$dest_vol"/.ChameleonEFI ]; then␊ |
# The Standard install option chosen␊ |
␊ |
␉␉# Does and /Extra folder already exist?␊ |
␉␉if [ -e "$dest_vol"/Extra ]; then␊ |
␉␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"␊ |
␉␉␉mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )␊ |
␉␉fi␊ |
␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"␊ |
␉␉cp -R "$chamTemp"/Extra "$dest_vol"␊ |
␉else␊ |
␉␉# The EFI system partition install option was chosen␊ |
# Does and /Extra folder already exist?␊ |
if [ -e "$dest_vol"/Extra ]; then␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"␊ |
mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )␊ |
fi␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"␊ |
cp -R "$chamTemp"/Extra "$dest_vol"␊ |
else␊ |
# The EFI system partition install option was chosen␊ |
␊ |
␉␉# Does a /Volumes/Extra folder already exist?␊ |
␉␉if [ -e "/Volumes/EFI/Extra" ]; then␊ |
␉␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"␊ |
␉␉␉mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )␊ |
␉␉fi␊ |
␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"␊ |
␉␉cp -R "$chamTemp"/Extra "/Volumes/EFI"␊ |
# Does a /Volumes/Extra folder already exist?␊ |
if [ -e "/Volumes/EFI/Extra" ]; then␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"␊ |
mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )␊ |
fi␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"␊ |
cp -R "$chamTemp"/Extra "/Volumes/EFI"␊ |
␊ |
␉␉# unmount /Volumes/EFI␊ |
␉␉attempts=1␊ |
␉␉while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do␊ |
␉␉␉echo "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
␉␉␉"$scriptDir"InstallLog.sh "${dest_vol}" "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
␉ ␉␉umount -f $( df | grep EFI | awk '{print $1}' )␊ |
␉␉␉attempts=$(( ${attempts} + 1 ))␊ |
␉␉done␊ |
␉fi␊ |
# unmount /Volumes/EFI␊ |
attempts=1␊ |
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do␊ |
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
umount -f $( df | grep EFI | awk '{print $1}' )␊ |
attempts=$(( ${attempts} + 1 ))␊ |
done␊ |
fi␊ |
fi␊ |
else␊ |
echo "Removing /.ChameleonExists file"␊ |
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 4"␊ |
rm "$dest_vol"/.ChameleonExists␊ |
fi␊ |
␊ |
# ---------------------------------------------␊ |