Skip to content

Commit

Permalink
Fix permission macos installer
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-service-account authored and hiento09 committed Sep 23, 2024
1 parent eddd0e3 commit 19890bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions engine/templates/macos/create_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions engine/templates/macos/postinstall
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 19890bd

Please sign in to comment.