File: //opt/resolve/scripts/uninstall.sh
#!/bin/bash
# Installer will replace PRODUCT_INSTALL_LOCATION with actual install path
INSTALL_DIR="PRODUCT_INSTALL_LOCATION"
RESOLVE_APP_NAME=com.blackmagicdesign.resolve
if [[ $EUID -ne 0 ]]; then
# Script being run as non-root user
USER_UID=$EUID
else
# Script being run as root
USER_UID=$SUDO_UID
if [ -z "$USER_UID" ]; then
USER_UID=$PKEXEC_UID
fi
if [ -z "$USER_UID" ]; then
USER_UID=0
fi
fi
USER_HOME=`awk -v val=$USER_UID -F ":" '\$3==val{print \$6;exit}' /etc/passwd`
uninstall_desktop_icons()
{
rm -vf "${USER_HOME}/Desktop/${RESOLVE_APP_NAME}.desktop"
rm -vf "${USER_HOME}/Desktop/DaVinci Resolve.desktop"
}
remove_if_empty()
{
FILES_COUNT=$(find "$1" -type f | wc -l)
if [[ $FILES_COUNT == 0 ]]; then
rm -rvf "$1"
fi
}
do_uninstall()
{
LIST_OF_DIRS=(
"libs"
"Control"
"graphics"
"Onboarding"
"plugins"
"scripts"
"share"
"UI_Resource"
"GPUCache"
)
# Delete all the files that came with the bundle
if [ -e "${INSTALL_DIR}/filelist.txt" ]; then
while IFS= read -r file || [[ -n "${file}" ]]; do
FILE_LIST+=("${file}")
done < "${INSTALL_DIR}/filelist.txt"
#delete all the files in the first pass
for file in "${FILE_LIST[@]}"; do
if [ -f "${INSTALL_DIR}/${file}" ]; then
rm -vf "${INSTALL_DIR}/${file}"
fi
done
# delete all the empty dirs
for dir in "${FILE_LIST[@]}"; do
if [ -d "${INSTALL_DIR}/${dir}" ]; then
remove_if_empty "${INSTALL_DIR}/${dir}"
fi
done
else
echo "Cant file ${INSTALL_DIR}/filelist.txt. Some of the files may not be deleted"
fi
# Remove all the major dirs
for dir in "${LIST_OF_DIRS[@]}"; do
rm -rvf "${INSTALL_DIR}/${dir}"
done
# Resolve Plugin
rm -rf "/usr/OFX/Plugins/DaVinci Resolve Renderer.ofx.bundle"
}
remove_app_shortcuts()
{
rm -vf "${USER_HOME}/.local/share/applications/${RESOLVE_APP_NAME}.desktop"
rm -vf "${USER_HOME}/.local/share/applications/${RESOLVE_APP_NAME}-Installer.desktop"
rm -vf "${USER_HOME}/.local/share/applications/${RESOLVE_APP_NAME}-CaptureLogs.desktop"
rm -vf "${USER_HOME}/.local/share/applications/${RESOLVE_APP_NAME}-Panels.desktop"
rm -vf "${USER_HOME}/.local/share/applications/${RESOLVE_APP_NAME}-DaVinciRemoteMonitoring.desktop"
rm -vf "${USER_HOME}/.local/share/applications/com.blackmagicdesign.rawplayer.desktop"
rm -vf "${USER_HOME}/.local/share/applications/com.blackmagicdesign.rawspeedtest.desktop"
if [ -e "${USER_HOME}/.config/menus/applications-merged" ]; then
rm -vf "${USER_HOME}/.config/menus/applications-merged/${RESOLVE_APP_NAME}.menu"
else
rm -vf "${USER_HOME}/.config/menus/${RESOLVE_APP_NAME}.menu"
fi
if [[ $EUID == 0 ]]; then
rm -vf "/usr/share/applications/${RESOLVE_APP_NAME}.desktop"
rm -vf "/usr/share/applications/${RESOLVE_APP_NAME}-Installer.desktop"
rm -vf "/usr/share/applications/${RESOLVE_APP_NAME}-CaptureLogs.desktop"
rm -vf "/usr/share/applications/${RESOLVE_APP_NAME}-Panels.desktop"
rm -vf "/usr/share/applications/${RESOLVE_APP_NAME}-DaVinciRemoteMonitoring.desktop"
rm -vf "/usr/share/desktop-directories/${RESOLVE_APP_NAME}.directory"
rm -vf "/etc/xdg/menus/applications-merged/${RESOLVE_APP_NAME}.menu"
rm -vf "/usr/share/applications/com.blackmagicdesign.rawplayer.desktop"
rm -vf "/usr/share/applications/com.blackmagicdesign.rawspeedtest.desktop"
fi
}
#Entry point for Uninstall script
echo "Uninstalling DaVinci Resolve from ${INSTALL_DIR}"
remove_app_shortcuts
if [[ $EUID -eq 0 ]]; then
SHARE_DIR=/usr/share
else
SHARE_DIR="${USER_HOME}/.local/share"
fi
xdg-mime uninstall --novendor "${INSTALL_DIR}/share/resolve.xml" 2>&1 >> /dev/null
xdg-mime uninstall --novendor "${INSTALL_DIR}/share/blackmagicraw.xml" 2>&1 >> /dev/null
xdg-icon-resource uninstall --size 64 DaVinci-Resolve 2>&1 >> /dev/null
xdg-icon-resource uninstall --size 64 DaVinci-ResolveProj 2>&1 >> /dev/null
xdg-icon-resource uninstall --size 64 DaVinci-ResolveDbKey 2>&1 >> /dev/null
echo "Updating icon cache"
gtk-update-icon-cache "${SHARE_DIR}/icons/hicolor" -f 2>&1 >> /dev/null
update-mime-database "${SHARE_DIR}/mime/" 2>&1 >> /dev/null
echo "Uninstalling desktop icons"
uninstall_desktop_icons
do_uninstall
exit 0