2023-07-19 22:46:19 +02:00

58 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# fahcontrol onquit
# do that which should not be done while installer is running
# nothing in here is needed if user used the uninstall pkg
# this is to fix mistakes and fight app relocation
# fah ~7.5.1 changed bundleid to org.foldinathome.*
# this caused app relocation for an upgrade install
if [ "$1" != "--delayed-action" ]; then
"$0" --delayed-action "$@" &
exit 0
fi
shift
# Wait up to 1 minute for Installer.app to quit
I=0
while $(ps axww|grep -v grep|grep Installer.app >/dev/null 2>&1); do
sleep 1
let I+=1
if [ $I -ge 60 ]; then break; fi
done
if [ $I -lt 1 ]; then sleep 1; fi
# move app if it was relocated to old place
# move must delayed becuase installd will try to register app in installed
# location after all scripts have been run, although it seems to just be a
# harmless error message in installer log
A1="/Applications/FAHControl.app"
A2="/Applications/Folding@home/FAHControl.app"
if [ -d "$A1" ]; then
if [ ! -d "$A2" ]; then
mv "$A1" "$A2"
else
# app was not relocated; delete old one (should only happen on 10.5)
rm -rf "$A1"
fi
fi
# ensure no old group writeable in std install locations
# (installer overwrite will not change directory permissions)
if [ -d "$A1" ]; then chmod -R go-w "$A1"; fi
if [ -d "$A2" ]; then chmod -R go-w "$A2"; fi
A3="/Applications/Folding@home/FAHControl/FAHControl.app"
F1="/Applications/Folding@home/FAHControl/.DS_Store"
D1="/Applications/Folding@home/FAHControl"
[ -d "$A3" ] && [ ! -d "$A2" ] && mv "$A3" "$A2" || true
[ -f "$F1" ] && rm -f "$F1" || true
[ -d "$D1" ] && rmdir "$D1" || true
# fix incorrect perms, which may persist from old pkg mistake
D1="/Applications/Folding@home"
[ -d "$D1" ] && chmod 0755 "$D1" || true