Skip to content

Commit 71f9239

Browse files
author
Chris Maunder
committed
Corrections for macOS Sonoma
1 parent 8c20e58 commit 71f9239

File tree

2 files changed

+78
-58
lines changed

2 files changed

+78
-58
lines changed

src/SDK/Scripts/utils.sh

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ function CreateWriteableDir () {
286286
if [ ! -d "${path}" ]; then
287287
write "Creating ${desc} folder..." $color_primary
288288
#sudo
289-
mkdir -p "${path}" >/dev/null 2>/dev/null
289+
if [ "${verbosity}" = "loud" ]; then
290+
mkdir -p "${path}"
291+
else
292+
mkdir -p "${path}" >/dev/null 2>/dev/null
293+
fi
290294
if [ $? -eq 0 ]; then
291295
writeLine "done" $color_success
292296
else
@@ -1701,9 +1705,9 @@ function installRequiredPythonPackages () {
17011705
# writeLine "${venvPythonCmdPath} -m pip install $pipFlags -r ${requirementsPath} --target ${packagesDirPath}" $color_info
17021706
write 'Installing Packages into Virtual Environment...' $color_primary
17031707
if [ "${verbosity}" = "loud" ]; then
1704-
"$venvPythonCmdPath" -m pip install $pipFlags -r "${requirementsPath}" --target ${packagesDirPath}
1708+
"$venvPythonCmdPath" -m pip install $pipFlags -r "${requirementsPath}" --target "${packagesDirPath}"
17051709
else
1706-
"$venvPythonCmdPath" -m pip install $pipFlags -r "${requirementsPath}" --target ${packagesDirPath} > /dev/null &
1710+
"$venvPythonCmdPath" -m pip install $pipFlags -r "${requirementsPath}" --target "${packagesDirPath}" > /dev/null &
17071711
spin $!
17081712
fi
17091713
writeLine 'Success' $color_success
@@ -1777,9 +1781,9 @@ function installRequiredPythonPackages () {
17771781
if [ "${os}" = "linux" ] || [ "${os}" = "macos" ]; then
17781782
# No, I don't know why eval is needed in Linux but not elsewhere
17791783
if [ "${verbosity}" = "loud" ]; then
1780-
eval "${venvPythonCmdPath}" -m pip install "${package_name}" --target "${packagesDirPath}" ${currentOption} ${pipFlags}
1784+
eval "\${venvPythonCmdPath}" -m pip install "${package_name}" --target "\${packagesDirPath}" ${currentOption} ${pipFlags}
17811785
else
1782-
eval "${venvPythonCmdPath}" -m pip install "${package_name}" --target "${packagesDirPath}" ${currentOption} ${pipFlags} >/dev/null 2>/dev/null &
1786+
eval "\${venvPythonCmdPath}" -m pip install "${package_name}" --target "\${packagesDirPath}" ${currentOption} ${pipFlags} >/dev/null 2>/dev/null &
17831787
spin $!
17841788
fi
17851789
else
@@ -2193,9 +2197,9 @@ function getValueFromModuleSettingsFile () {
21932197
local moduleId=$2
21942198
local property=$3
21952199

2196-
# if [ "$verbosity" = "loud" ]; then
2197-
# echo "Searching for '${property}' in a suitable modulesettings.json file in ${moduleDirPath}" >&3
2198-
# fi
2200+
if [ "$verbosity" = "loud" ] && [ "$debug_json_parse" == "true" ]; then
2201+
echo "Searching for '${property}' in a suitable modulesettings.json file in ${moduleDirPath}" >&3
2202+
fi
21992203

22002204
# Module settings files are loaded in this order. Each file will overwrite (but not delete)
22012205
# settings of the previous file. Becuase of this, we're going to search the files in REVERSE
@@ -2250,7 +2254,7 @@ function getValueFromModuleSettingsFile () {
22502254
if [ "${moduleSettingValue}" != "" ]; then settings_file_used="modulesettings.json"; fi
22512255
fi
22522256

2253-
if [ false ] && [ "$verbosity" = "loud" ]; then
2257+
if [ "$verbosity" = "loud" ] && [ "$debug_json_parse" == "true" ]; then
22542258
if [ "${moduleSettingValue}" = "" ]; then
22552259
echo "Cannot find ${moduleId}.${property} in modulesettings in ${moduleDirPath}" >&3
22562260
else
@@ -2303,7 +2307,10 @@ function getValueFromModuleSettings () {
23032307
key=$".Modules.${moduleId}.${property}"
23042308
fi
23052309

2306-
# echo jsonFile is $json_file >&3
2310+
if [ "$verbosity" = "loud" ] && [ "$debug_json_parse" == "true" ]; then
2311+
echo jsonFile is $json_file >&3
2312+
echo parse_mode is $parse_mode >&3
2313+
fi
23072314

23082315
if [ -f "$json_file" ]; then
23092316
if [ "$parse_mode" = "jq" ]; then
@@ -2332,9 +2339,7 @@ function getValueFromModuleSettings () {
23322339

23332340
# Do the extraction
23342341
jsonValue=$(echo "$file_contents" | jq -r "$key")
2335-
# echo "jsonValue = $jsonValue" >&3
2336-
# quit
2337-
2342+
23382343
elif [ "$parse_mode" = "parsejson" ]; then
23392344

23402345
# Let's back in this huge earth mover to plant my flower pots. Even
@@ -2366,9 +2371,10 @@ function getValueFromModuleSettings () {
23662371
# Really??
23672372
if [ "$jsonValue" == "null" ]; then jsonValue=""; fi
23682373

2369-
# debug
2370-
# if [ "$verbosity" = "loud" ]; then echo "${key} = $jsonValue" >&3; fi
2371-
2374+
if [ "$verbosity" = "loud" ] && [ "$debug_json_parse" == "true" ]; then
2375+
echo "${key} = $jsonValue" >&3;
2376+
fi
2377+
23722378
echo $jsonValue
23732379
}
23742380

@@ -2516,23 +2522,34 @@ function displayMacOSDirCreatePermissionError () {
25162522

25172523
haveDisplayedMacOSDirCreatePermissionError=true
25182524

2525+
writeLine ''
25192526
writeLine ''
25202527
writeLine 'We may be able to suggest something:' $color_info
25212528

2522-
# Note that  will appear as the Apple symbol on macOS, but probably not on Windows or Linux
2523-
writeLine '1. Pull down the  Apple menu and choose "System Preferences"'
2524-
writeLine '2. Choose “Security & Privacy” control panel'
2525-
writeLine '3. Now select the “Privacy” tab, then from the left-side menu select'
2526-
writeLine ' “Full Disk Access”'
2527-
writeLine '4. Click the lock icon in the lower left corner of the preference '
2528-
writeLine ' panel and authenticate with an admin level login'
2529-
writeLine '5. Now click the [+] plus button so we can full disk access to Terminal'
2530-
writeLine "6. Navigate to the /Applications/Utilities/ folder and choose 'Terminal'"
2531-
writeLine ' to grant Terminal Full Disk Access privileges'
2532-
writeLine '7. Relaunch Terminal, the “Operation not permitted” error messages should'
2533-
writeLine ' be gone'
2534-
writeLine
2535-
writeLine 'Thanks to https://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/'
2529+
if [ "$os_name" = "Sonoma" ]; then # macOS 14 / Kernal 23
2530+
# Note that  will appear as the Apple symbol on macOS, but probably not on Windows or Linux
2531+
writeLine '1. Pull down the  Apple menu and choose "System Settings"'
2532+
writeLine '2. Choose “Privacy & Security"'
2533+
writeLine '3. Scroll down to “Full Disk Access” and click the right arrow >'
2534+
writeLine '4. Click the [+] plus button, and in the popup, navigate to the'
2535+
writeLine ' /Applications/Utilities/ folder and choose "Terminal"'
2536+
writeLine '5. Relaunch Terminal. The “Operation not permitted” error messages should'
2537+
writeLine ' be gone'
2538+
else
2539+
writeLine '1. Pull down the  Apple menu and choose "System Preferences"'
2540+
writeLine '2. Choose “Security & Privacy” control panel'
2541+
writeLine '3. Now select the “Privacy” tab, then from the left-side menu select'
2542+
writeLine ' “Full Disk Access”'
2543+
writeLine '4. Click the lock icon in the lower left corner of the preference '
2544+
writeLine ' panel and authenticate with an admin level login'
2545+
writeLine '5. Now click the [+] plus button so we can full disk access to Terminal'
2546+
writeLine "6. Navigate to the /Applications/Utilities/ folder and choose 'Terminal'"
2547+
writeLine ' to grant Terminal Full Disk Access privileges'
2548+
writeLine '7. Relaunch Terminal, the “Operation not permitted” error messages should'
2549+
writeLine ' be gone'
2550+
fi
2551+
2552+
writeLine ''
25362553
fi
25372554

25382555
# quit 8 # unable to create file or directory

src/setup.sh

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ oneStepPIP=false
9595

9696
# Whether or not to use the jq utility for JSON parsing
9797
useJq=true
98-
98+
debug_json_parse=false
9999

100100
# Basic locations
101101

@@ -717,20 +717,20 @@ writeLine "${formattedFreeSpace} of ${formattedTotalSpace} available on ${system
717717

718718
if [ "$verbosity" != "quiet" ]; then
719719
writeLine
720-
writeLine "os, arch = ${os} ${architecture}" $color_mute
721-
writeLine "systemName, platform = ${systemName}, ${platform}" $color_mute
722-
writeLine "edgeDevice = ${edgeDevice}" $color_mute
723-
writeLine "SSH = ${inSSH}" $color_mute
724-
writeLine "setupMode = ${setupMode}" $color_mute
725-
writeLine "executionEnvironment = ${executionEnvironment}" $color_mute
726-
writeLine "rootDirPath = ${rootDirPath}" $color_mute
727-
writeLine "appRootDirPath = ${appRootDirPath}" $color_mute
728-
writeLine "setupScriptDirPath = ${setupScriptDirPath}" $color_mute
729-
writeLine "sdkScriptsDirPath = ${sdkScriptsDirPath}" $color_mute
730-
writeLine "runtimesDirPath = ${runtimesDirPath}" $color_mute
731-
writeLine "modulesDirPath = ${modulesDirPath}" $color_mute
732-
writeLine "externalModulesDirPath = ${externalModulesDirPath}" $color_mute
733-
writeLine "downloadDirPath = ${downloadDirPath}" $color_mute
720+
writeLine "os, name, arch = ${os} ${os_name} ${architecture}" $color_mute
721+
writeLine "systemName, platform = ${systemName}, ${platform}" $color_mute
722+
writeLine "edgeDevice = ${edgeDevice}" $color_mute
723+
writeLine "SSH = ${inSSH}" $color_mute
724+
writeLine "setupMode = ${setupMode}" $color_mute
725+
writeLine "executionEnvironment = ${executionEnvironment}" $color_mute
726+
writeLine "rootDirPath = ${rootDirPath}" $color_mute
727+
writeLine "appRootDirPath = ${appRootDirPath}" $color_mute
728+
writeLine "setupScriptDirPath = ${setupScriptDirPath}" $color_mute
729+
writeLine "sdkScriptsDirPath = ${sdkScriptsDirPath}" $color_mute
730+
writeLine "runtimesDirPath = ${runtimesDirPath}" $color_mute
731+
writeLine "modulesDirPath = ${modulesDirPath}" $color_mute
732+
writeLine "externalModulesDirPath = ${externalModulesDirPath}" $color_mute
733+
writeLine "downloadDirPath = ${downloadDirPath}" $color_mute
734734
writeLine
735735
fi
736736

@@ -925,20 +925,23 @@ if [ "$setupMode" = 'SetupEverything' ]; then
925925
writeLine "Processing Included CodeProject.AI Server Modules" "White" "DarkGreen" $lineWidth
926926
writeLine
927927

928-
for d in ${modulesDirPath}/*/ ; do
929-
moduleDirName=$(basename "$d")
930-
moduleDirPath="${modulesDirPath}/${moduleDirName}"
931-
moduleId=$(getModuleIdFromModuleSettings "${moduleDirPath}/modulesettings.json")
928+
if [ -d "$modulesDirPath" ]; then
929+
for d in "${modulesDirPath}/"*/ ; do # Note the " placement here
932930

933-
currentDir="$(pwd)"
934-
doModuleInstall "${moduleId}" "${moduleDirPath}"
935-
cd "$currentDir" >/dev/null
931+
moduleDirName=$(basename "$d")
932+
moduleDirPath="${modulesDirPath}/${moduleDirName}"
933+
moduleId=$(getModuleIdFromModuleSettings "${moduleDirPath}/modulesettings.json")
936934

937-
if [ "${module_install_errors}" != "" ]; then
938-
success=false
939-
writeLine "Install failed: ${module_install_errors}" "$color_error"
940-
fi
941-
done
935+
currentDir="$(pwd)"
936+
doModuleInstall "${moduleId}" "${moduleDirPath}"
937+
cd "$currentDir" >/dev/null
938+
939+
if [ "${module_install_errors}" != "" ]; then
940+
success=false
941+
writeLine "Install failed: ${module_install_errors}" "$color_error"
942+
fi
943+
done
944+
fi
942945

943946
if [ "$installExternalModules" == "true" ]; then
944947
# Walk through the modules directoorym for modules that live in the external
@@ -949,7 +952,7 @@ if [ "$setupMode" = 'SetupEverything' ]; then
949952
writeLine
950953

951954
if [ -d "$externalModulesDirPath" ]; then
952-
for d in ${externalModulesDirPath}/*/ ; do
955+
for d in "${externalModulesDirPath}/"*/ ; do # Note the " placement here
953956
moduleDirName=$(basename "$d")
954957
moduleDirPath="${externalModulesDirPath}/${moduleDirName}"
955958
moduleId=$(getModuleIdFromModuleSettings "${moduleDirPath}/modulesettings.json")

0 commit comments

Comments
 (0)