diff --git a/omnibus/config/projects/chef-workstation.rb b/omnibus/config/projects/chef-workstation.rb index 9566a5e79e..d5556be48f 100644 --- a/omnibus/config/projects/chef-workstation.rb +++ b/omnibus/config/projects/chef-workstation.rb @@ -120,6 +120,7 @@ dependency "nodejs-binary" dependency "chef-workstation-app" +dependency "uninstall-scripts" dependency "chef-cleanup" exclude "**/.git" diff --git a/omnibus/config/software/uninstall-scripts.rb b/omnibus/config/software/uninstall-scripts.rb new file mode 100644 index 0000000000..6bbea6c677 --- /dev/null +++ b/omnibus/config/software/uninstall-scripts.rb @@ -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 \ No newline at end of file diff --git a/omnibus/files/uninstall-scripts/uninstall.sh b/omnibus/files/uninstall-scripts/uninstall.sh new file mode 100755 index 0000000000..c19cfeb352 --- /dev/null +++ b/omnibus/files/uninstall-scripts/uninstall.sh @@ -0,0 +1,38 @@ +#!/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 + echo "Closing Chef Workstation App" + osascript -e 'quit app "Chef Workstation App"' + sudo -s -- </dev/null 2>&1