-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-telavox.sh
executable file
·96 lines (75 loc) · 2.8 KB
/
install-telavox.sh
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
90
91
92
93
94
95
#!/bin/bash
TELAVOX_URL='https://deopappmanager.telavox.com/flow/download/mac/latest'
APP_LOCATION=/Applications/Telavox.app
echo "`date` | Running Telavox installer with args $@"
FORCE=0
if [[ "$4" == "--force" ]]; then
echo "`date` | Forcing install"
FORCE=1
fi
echo "`date` | Fetching Telavox version from $TELAVOX_URL"
DOWNLOAD_URL=$(curl $TELAVOX_URL -i | grep Location: | awk {'print $2'})
FILE_NAME=$(echo $DOWNLOAD_URL | sed -r 's/.*\///' | sed -r 's/\.dmg//g')
LATEST_VERSION=$(echo $FILE_NAME | sed -r 's/\.dmg//g' | sed 's/.*-//' | sed -e 's/[^0-9]*\([0-9]*\)%.*/\1/' | tr -d '\r')
LATEST_VERSION="$LATEST_VERSION"
echo "`date` | Latest version is $LATEST_VERSION from Telavox"
if [ -e $APP_LOCATION ]; then
CURRENT_VERSION=$(defaults read "$APP_LOCATION/Contents/info" CFBundleShortVersionString)
echo "`date` | Installed version is $CURRENT_VERSION at $APP_LOCATION"
if [[ "$LATEST_VERSION" == "$CURRENT_VERSION" ]]; then
echo "`date` | Already on the latest version"
if [[ $FORCE == 0 ]]; then
echo "`date` | Not forcing install, exiting"
exit 0
fi
echo "`date` | Forcing install"
fi
else
echo "`date` | No installation found"
fi
TMP_LOCATION=/private/var/tmp/telavox.dmg
echo "`date` | Downloading installer disk image from $DOWNLOAD_URL"
curl $TELAVOX_URL -L -o $TMP_LOCATION
if [ -e $TMP_LOCATION ]; then
echo "`date` | Downloaded to $TMP_LOCATION"
else
echo "`date` | Could not find any downloads on $TMP_LOCATION"
exit 1
fi
while true; do
MOUNT_PATH=$(df | grep Telavox | sed '1q' | awk '{print $1}')
if [ -z $MOUNT_PATH ]; then
break
elif [ -e $MOUNT_PATH ]; then
echo "`date` | Detaching $MOUNT_PATH."
hdiutil detach $MOUNT_PATH -quiet
fi
done
echo "`date` | Mounting installer disk image."
hdiutil mount $TMP_LOCATION -noverify -nobrowse -noautoopen -quiet
sleep 10
MOUNT_NAME=$(df | grep Telavox | sed '1q' | sed 's/.*Volumes/\/Volumes/' | sed 's/\ *$//g')
if [ -e "$MOUNT_NAME" ]; then
echo "`date` | Mounted on $MOUNT_NAME"
else
echo "`date` | Could not mount dmg"
rm $TMP_LOCATION
exit 1
fi
echo "`date` | Killing Telavox if running."
killall Telavox || echo
echo "`date` | Removing old app at $APP_LOCATION."
rm -rf $APP_LOCATION
echo "`date` | Copying app to $APP_LOCATION"
cp -af "$MOUNT_NAME/Telavox.app" /Applications/
echo "`date` | Changing permissions on $APP_LOCATION"
chown -R root:wheel $APP_LOCATION
chmod -R 755 $APP_LOCATION
echo "`date` | Adding quarantine exception for $APP_LOCATION"
spctl --add --label "Telavox" $APP_LOCATION
# chmod +x /Applications/Telavox.app/Contents/MacOS/Telavox || echo
echo "`date` | Unmounting disk image"
hdiutil detach $(df | grep Telavox | awk '{print $1}') -quiet
sleep 10
echo "`date` | Deleting disk image."
rm $TMP_LOCATION