-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-patch
More file actions
executable file
·89 lines (72 loc) · 2.4 KB
/
install-patch
File metadata and controls
executable file
·89 lines (72 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Patches GrowlVoice with @kroo's fix.
#
# To undo this patch:
# - delete /Library/Application Support/GrowlVoice
# - delete /Library/LaunchDaemons/com.interestinglythere.fixGrowlVoice.plist
# - launchctl remove com.interestinglythere.fixGrowlVoice
#
# To revert the GrowlVoice app manually
# - replace /path/to/GrowlVoice.app/Contents with /path/to/GrowlVoice.app/Contents/MacOS/GrowlVoice.app/Contents
# or run: unpatch-app /path/to/GrowlVoice.app
set -e
## Variables ##
if [ -z "$1" ] ; then
APP='/Applications/GrowlVoice.app'
else
APP="$1"
fi
# Remove trailing slash
APP="${APP%/}"
# Absolute paths only
if [[ ! "$APP" = /* ]] ; then
APP="$(pwd)"/"$APP"
echo "APP = $APP"
fi
if [ ! -d "$APP" ] ; then
echo "GrowlVoice doesn't exist at $APP."
echo "usage: sudo $0 [/path/to/GrowlVoice.app]"
exit 1
fi
SRC_DIR='patch_files'
LAUNCHD_DIR='/Library/LaunchDaemons'
SUPPORT_DIR='/Library/Application Support/GrowlVoice'
CYCRIPT_DIR="$SUPPORT_DIR"/'cycript'
APP_NAME='GrowlVoice.app'
NEW_APP="$APP"/'Contents/MacOS'/"$APP_NAME"
EXE_NAME='GrowlVoice'
HELPER_EXE="$APP"/'Contents/MacOS'/"$EXE_NAME"
SIGNAL="$SUPPORT_DIR"/'patch_now'
set -x
cd "$(dirname "$0")"
rm -rf "$SUPPORT_DIR"
## Install cycript ##
echo 'Install cycript'
mkdir -p "$CYCRIPT_DIR"
curl -L 'https://cydia.saurik.com/api/latest/3' -o '/tmp/cycript-'"$$"'.zip'
unzip '/tmp/cycript-'"$$"'.zip' -d "$CYCRIPT_DIR"
cp "$SRC_DIR"/'fix_growlvoice.js' "$SUPPORT_DIR"/
cp "$SRC_DIR"/'fix_growlvoice.sh' "$SUPPORT_DIR"/
chmod u+x "$SUPPORT_DIR"/'fix_growlvoice.sh'
cp "$SRC_DIR"/'patch-now' "$SUPPORT_DIR"/
chmod a+x "$SUPPORT_DIR"/'patch-now'
## Make a backup & unpatch ##
echo 'Make a backup & unpatch'
cp -RPp "$APP" "$APP"' (Backup '"$(date '+%Y%m%d.%H%M%S')"').app'
./unpatch-app "$APP"
## Move stuff ##
echo 'Move stuff'
mv "$APP"/'Contents' "$APP"/'Contents-old'
mkdir -p "$NEW_APP"
mv "$APP"/'Contents-old' "$NEW_APP"/'Contents'
ln -s 'MacOS'/"$APP_NAME"/'Contents'/{'Info.plist','Resources','PkgInfo'} "$APP"/'Contents'/
## Install helper ##
echo 'Install helper'
cp "$SRC_DIR"/'GrowlVoice-helper' "$HELPER_EXE"
chmod 777 "$HELPER_EXE"
## Install LaunchDaemon ##
echo 'Install LaunchDaemon'
cp "$SRC_DIR"/'com.interestinglythere.fixGrowlVoice.plist' "$LAUNCHD_DIR"/
rm -f "$SIGNAL"
launchctl remove 'com.interestinglythere.fixGrowlVoice' || true # don't fail on error
launchctl load '/Library/LaunchDaemons'/'com.interestinglythere.fixGrowlVoice.plist'