Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac_os:(launcher) run at boot #913

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions omnibus/files/uninstall-scripts/uninstall_chef_workstation
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ is_darwin()
if is_darwin; then
echo "This uninstaller will remove Chef Workstation."
sudo /bin/sh -s <<'EOF'
if [ $(osascript -e 'application "Chef Workstation App" is running') = 'true' ]; then
echo "Closing Chef Workstation App..."
osascript -e 'quit app "Chef Workstation App"' > /dev/null 2>&1;
fi
echo "Uninstalling Chef Workstation..."
echo " -> Removing Chef Workstation App..."
/opt/chef-workstation/bin/chef_workstation_app_launcher remove
echo " -> Removing files..."
sudo rm -rf '/opt/chef-workstation'
sudo rm -rf '/Applications/Chef Workstation App.app'
Expand Down
13 changes: 7 additions & 6 deletions omnibus/package-scripts/chef-workstation/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ for binary in $binaries; do
done

if is_darwin; then
restart_required=false
# the app launcher comes from the chef-workstation-app repo, here we are just using
# it to start the app as a service on MacOS systems, it will start at boot
app_launcher=chef_workstation_app_launcher

# Close the app if it is running.
if [ $(osascript -e 'application "Chef Workstation App" is running') = 'true' ]; then
restart_required=true
echo "Closing Chef Workstation App..."
osascript -e 'quit app "Chef Workstation App"' > /dev/null 2>&1;
fi
Expand All @@ -48,16 +50,15 @@ if is_darwin; then
unzip chef-workstation-app-mac.zip
sudo rm -rf "/Applications/Chef Workstation App.app"
sudo mv "Chef Workstation App.app" /Applications/
mv "/Applications/Chef Workstation App.app/Contents/Resources/assets/scripts/$app_launcher" $INSTALLER_DIR/bin || error_exit "Cannot move $app_launcher to $INSTALLER_DIR/bin"
rm -f chef-workstation-app-mac.zip
popd

ln -sf $INSTALLER_DIR/bin/uninstall_chef_workstation $PREFIX/bin || error_exit "Cannot link uninstall_chef_workstation to $PREFIX/bin"

# Restart the app if it was running.
if $restart_required; then
echo "Restarting Chef Workstation App..."
osascript -e 'open app "Chef Workstation App"' > /dev/null 2>&1;
fi
echo "Restarting Chef Workstation App..."
$INSTALLER_DIR/bin/$app_launcher load
else # linux - postinst does not run for windows.
cwa_app_path="$INSTALLER_DIR/components/chef-workstation-app/chef-workstation-app"
ldd "$cwa_app_path" | grep "not found" >/dev/null 2>&1
Expand Down