Skip to content

Commit

Permalink
Mac uninstall program
Browse files Browse the repository at this point in the history
This change adds an uninstall program for macs.

Signed-off-by: Jon Morrow <jmorrow@chef.io>
  • Loading branch information
Jon Morrow committed Oct 11, 2018
1 parent a007a4b commit 6d7e053
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions omnibus/config/projects/chef-workstation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@

dependency "nodejs-binary"
dependency "chef-workstation-app"
dependency "uninstall-scripts"
dependency "chef-cleanup"

exclude "**/.git"
Expand Down
12 changes: 12 additions & 0 deletions omnibus/config/software/uninstall-scripts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name "uninstall-scripts"

source path: "#{project.files_path}/uninstall-scripts"

skip_transitive_dependency_licensing true
license :project_license

build do
if mac_os_x?
copy "#{project_dir}/uninstall.sh", "#{install_dir}/bin/uninstall_chef_workstation", { :preserve => true }
end
end
39 changes: 39 additions & 0 deletions omnibus/files/uninstall-scripts/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
# Perform necessary steps to unsinstall
# Chef Workstation.
#

PROGNAME=`basename $0`

error_exit()
{
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}

is_darwin()
{
uname -v | grep "^Darwin" 2>&1 >/dev/null
}

if is_darwin; then
echo "This uninstaller will remove Chef Workstation"
if ! sudo -n true 2>/dev/null; then
echo "Enter your password to continue"
fi
sudo -s -- <<EOF
echo "Uninstalling Chef Workstation"
pkgId='com.getchef.pkg.chef-workstation'
echo "Closing Chef Workstation App"
osascript -e 'quit app "Chef Workstation App"'
echo "Removing files"
sudo rm -rf '/opt/chef-workstation'
sudo rm -rf '/Applications/Chef Workstation App.app'
echo "Removing binary links in /usr/local/bin"
sudo find /usr/local/bin -lname '/opt/chef-workstation/*' -delete
echo "Forgeting $pkgId"
sudo pkgutil --forget $pkgId
echo "Chef Workstation Uninstalled"
EOF
fi
2 changes: 2 additions & 0 deletions omnibus/package-scripts/chef-workstation/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ if is_darwin; then
sudo mv "mac/Chef Workstation App.app" /Applications
rm -r mac
popd

ln -sf $INSTALLER_DIR/bin/uninstall_chef_workstation $PREFIX/bin || error_exit "Cannot link uninstall_chef_workstation to $PREFIX/bin"
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

0 comments on commit 6d7e053

Please sign in to comment.