Last active
June 7, 2021 14:22
-
-
Save rtrouton/94b8f1989b7c7d0c95ca to your computer and use it in GitHub Desktop.
Preinstall script for Sophos Enterprise Anti-Virus for Mac OS X 9.2.x installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOGGER="/usr/bin/logger" | |
# Determine working directory | |
install_dir=`dirname $0` | |
# Uninstall existing copy of Sophos 8.x by checking for the | |
# Sophos Antivirus uninstaller package in /Library/Sophos Anti-Virus. | |
# If present, the uninstallation process is run. | |
if [ -d "$3/Library/Sophos Anti-Virus/Remove Sophos Anti-Virus.pkg" ]; then | |
${LOGGER} "Sophos AV present on Mac. Uninstalling before installing new copy." | |
/usr/sbin/installer -pkg "$3/Library/Sophos Anti-Virus/Remove Sophos Anti-Virus.pkg" -target "$3" | |
killall SophosUIServer | |
elif [ -d "$3/Library/Application Support/Sophos Anti-Virus/Remove Sophos Anti-Virus.pkg" ]; then | |
${LOGGER} "Sophos AV present on Mac. Uninstalling before installing new copy." | |
/usr/sbin/installer -pkg "$3/Library/Application Support/Sophos Anti-Virus/Remove Sophos Anti-Virus.pkg" -target "$3" | |
killall SophosUIServer | |
else | |
${LOGGER} "Sophos Anti-Virus 8.x Uninstaller Not Present" | |
fi | |
# Uninstall existing copy of Sophos 9.x by checking for the InstallationDeployer application | |
# in the following locations: | |
# | |
# Sophos AV Cloud | |
# /Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/ | |
# /Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/ | |
# | |
# Sophos AV Home Edition | |
# /Library/Application Support/Sophos/he/Installer.app/Contents/MacOS | |
# /Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools | |
# | |
# Sophos AV Standalone | |
# /Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS | |
# /Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools | |
# | |
# Sophos AV Enterprise | |
# /Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS | |
# /Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools | |
# | |
# If the InstallationDeployer application is present in the Contents/MacOS/tools directory, the | |
# uninstallation process is run using the InstallationDeployer tool located there. | |
# | |
# If the InstallationDeployer application is present only in the Contents/MacOS directory, the | |
# uninstallation process is run using the InstallationDeployer tool located there. | |
# | |
# The reason for the directory-specific check is that running the InstallationDeployer application | |
# from Contents/MacOS on Sophos 9.1.x and later will cause the Sophos uninstaller application to | |
# launch in the dock and interfere with a normal installation via installer package. | |
# | |
# For more information, see the link below: | |
# http://www.sophos.com/en-us/support/knowledgebase/14179.aspx | |
if [[ -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ ! -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Home Edition present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/InstallationDeployer" --remove | |
elif [[ -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Home Edition present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
elif [[ ! -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Home Edition present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/he/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
else | |
${LOGGER} "Sophos Anti-Virus 9.x Home Edition Uninstaller Not Present" | |
fi | |
if [[ -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ ! -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Standalone present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/InstallationDeployer" --remove | |
elif [[ -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Standalone present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
elif [[ ! -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Standalone present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm-sa/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
else | |
${LOGGER} "Sophos Anti-Virus 9.x Standalone Uninstaller Not Present" | |
fi | |
if [[ -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ ! -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Enterprise present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/InstallationDeployer" --remove | |
elif [[ -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Enterprise present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
elif [[ ! -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Enterprise present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
else | |
${LOGGER} "Sophos Anti-Virus 9.x Enterprise Uninstaller Not Present" | |
fi | |
if [[ -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ ! -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Cloud present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/InstallationDeployer" --remove | |
elif [[ -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Cloud present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
elif [[ ! -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/InstallationDeployer" ]] && [[ -f "$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/InstallationDeployer" ]]; then | |
${LOGGER} "Sophos AV Cloud present on Mac. Uninstalling before installing new copy." | |
"$3/Library/Application Support/Sophos/saas/Installer.app/Contents/MacOS/tools/InstallationDeployer" --remove | |
else | |
${LOGGER} "Sophos Anti-Virus 9.x Cloud Uninstaller Not Present" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment