SymphonyElectron/installer/mac/postinstall.sh
2017-07-20 21:45:18 +05:30

51 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
## Create file path variables ##
tempFilePath='/tmp/sym_settings.txt'
installPath="$2"
configPath="/Symphony.app/Contents/config/Symphony.config"
newPath=$installPath$configPath
## Get Symphony Settings from the temp file ##
pod_url=$(sed -n '1p' $tempFilePath);
minimize_on_close=$(sed -n '2p' '/tmp/sym_settings.txt');
launch_on_startup=$(sed -n '3p' '/tmp/sym_settings.txt');
always_on_top=$(sed -n '4p' '/tmp/sym_settings.txt');
## Replace the default settings with the user selected settings ##
sed -i "" -E "s#\"url\" ?: ?\".*\"#\"url\"\: \"$pod_url\"#g" $newPath
sed -i "" -E "s#\"minimizeOnClose\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"minimizeOnClose\":\ $minimize_on_close#g" $newPath
sed -i "" -E "s#\"alwaysOnTop\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"alwaysOnTop\":\ $always_on_top#g" $newPath
sed -i "" -E "s#\"launchOnStartup\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"launchOnStartup\":\ $launch_on_startup#g" $newPath
## Add app to login items
if [ $launch_on_startup == true ]; then
mkdir ~/Library/LaunchAgents/
cat > ~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist << EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.symphony.symphony-desktop.agent</string>
<key>ProgramArguments</key>
<array>
<string>$installPath/Symphony.app/Contents/MacOS/Symphony</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOT
else
launchctl unload ~/Library/LaunchAgents/com.symphony.symphony-desktop.agent.plist
fi
## Remove the temp settings file created ##
rm -f $tempFilePath
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
exec $EXEC_PATH/Symphony --install $newPath
chmod 755 $EXEC_PATH/Symphony