forked from florentbr/OWON-VDS1022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-mac.sh
93 lines (70 loc) · 3.19 KB
/
install-mac.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
#!/bin/bash
set -e
pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null
_ID='owon-vds-tiny'
_NAME='OWON VDS1022 Oscilloscope'
_VERSION=$(<./version.txt)
_VENDOR='Copyright (C) Fujian Lilliput Optoelectronics Technology Co.,Ltd'
_SUMMARY='Application for the OWON VDS1022 oscilloscope'
_ARCH=$(uname -m)
write () {
echo -e "$(cat -)" > "$1"
[ -z "$2" ] || chmod "$2" "$1"
}
raise () {
printf "Error: $1\n\n" >&2
exit 1
}
echo "==========================================================="
echo " Install '${_NAME}' "
echo "==========================================================="
echo "Check environement ..."
[ $EUID -eq 0 ] || raise "This script requires eleveted privileges."
[ -d "lib/mac/$_ARCH" ] || raise "Architecture not supported: ${_ARCH}"
[ -d "/Applications" ] || raise "Folder /Applications missing"
echo "Locate Java Runtime ..."
JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null)
[ -d "$JAVA_HOME" ] || raise "Java not found. To install, visit adoptopenjdk.net or java.com"
echo "$JAVA_HOME"
echo "Install to /Applications/$_NAME.app ..."
rm -fr "/Applications/$_NAME.app"
mkdir -p "/Applications/$_NAME.app/Contents"/{MacOS,Resources}
cp -r fwr jar doc version.txt "/Applications/$_NAME.app/Contents/Resources/"
cp ico/icon48.icns "/Applications/$_NAME.app/Contents/Resources/icon.icns"
cp lib/mac/$_ARCH/* "/Applications/$_NAME.app/Contents/MacOS/"
write "/Applications/$_NAME.app/Contents/MacOS/$_ID" +x <<-EOF
#!/bin/bash
/usr/libexec/java_home --exec java\\
-Xdock:name='$_NAME'\\
-Xdock:icon='/Applications/$_NAME.app/Contents/Resources/icon.icns'\\
-Djava.library.path='/Applications/$_NAME.app/Contents/MacOS'\\
-Duser.dir="\$HOME/.$_ID"\\
-cp '/Applications/$_NAME.app/Contents/Resources/jar/*'\\
com.owon.vds.tiny.Main
EOF
write "/Applications/$_NAME.app/Contents/Info.plist" <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key> <string>English</string>
<key>CFBundleExecutable</key> <string>${_ID}</string>
<key>CFBundleName</key> <string>${_NAME}</string>
<key>CFBundleGetInfoString</key> <string>${_SUMMARY}</string>
<key>CFBundleIconFile</key> <string>icon.icns</string>
<key>CFBundleIdentifier</key> <string>${_ID}</string>
<key>CFBundleVersion</key> <string>${_VERSION}</string>
<key>CFBundleShortVersionString</key> <string>${_VERSION}</string>
<key>CFBundleInfoDictionaryVersion</key> <string>6.0</string>
<key>CFBundlePackageType</key> <string>APPL</string>
<key>CSResourcesFileMapped</key> <true/>
<key>LSRequiresCarbon</key> <true/>
<key>NSHumanReadableCopyright</key> <string>${_VENDOR}</string>
<key>NSPrincipalClass</key> <string>NSApplication</string>
<key>NSHighResolutionCapable</key> <true/>
</dict>
</plist>
EOF
echo 'Clear previous settings ...'
rm -f /home/*/".$_ID"/preferences*
printf "\nDone!\n"