diff --git a/engine/templates/macos/create_pkg.sh b/engine/templates/macos/create_pkg.sh index 74bcc1438..bf8cbcaf1 100644 --- a/engine/templates/macos/create_pkg.sh +++ b/engine/templates/macos/create_pkg.sh @@ -14,6 +14,8 @@ cp $SOURCE_BINARY_PATH installer/$DESTINATION_BINARY_NAME export DESTINATION_BINARY_NAME cp postinstall Scripts/postinstall sed -i '' "3s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" Scripts/postinstall +sed -i '' "4s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" Scripts/postinstall +sed -i '' "5s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" Scripts/postinstall chmod +x Scripts/postinstall export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME UNINSTALLER_FILE_NAME diff --git a/engine/templates/macos/postinstall b/engine/templates/macos/postinstall index 7382c2cd0..551f98dcf 100644 --- a/engine/templates/macos/postinstall +++ b/engine/templates/macos/postinstall @@ -1,8 +1,15 @@ #!/usr/bin/env sh set -e DESTINATION_BINARY_NAME=cortex -USER_TO_RUN_AS=${SUDO_USER:-$(whoami)} -echo "Download cortex.llamacpp engines by default" +DATA_FOLDER_NAME=.cortex +CONFIGURATION_FILE_NAME=.cortexrc + +USER_TO_RUN_AS=$(stat -f "%Su" /dev/console) + +echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS" sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME engines install cortex.llamacpp +sudo chown -R $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" +sudo chown $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" + exit 0 \ No newline at end of file