-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·56 lines (45 loc) · 1.19 KB
/
install.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
#!/bin/sh
package="Mark4Down"
TMP="${TMPDIR}"
if [ "x$TMP" = "x" ]; then
TMP="/tmp/"
fi
TMP="${TMP}$package.$$"
rm -rf "$TMP" || true
mkdir "$TMP"
if [ $? -ne 0 ]; then
echo "failed to mkdir $TMP" >&2
exit 1
fi
cd $TMP
echo "⬇️ Download last component"
archive=$TMP/Mark4Down.4dbase.zip
curl -sL https://github.com/mesopelagique/$package/releases/latest/download/$package.4dbase.zip -o $archive
unzip -q $archive -d $TMP/
src=$TMP/$package.4dbase
echo "🔍 Find 4D path"
dst="/Applications/4D.app"
if [ ! -d "$dst" ]; then
dst=$(mdfind kMDItemCFBundleIdentifier = "com.4D.4D" | head -n 1)
if [ -z "$dst" ];then
dst=$(mdfind kMDItemCFBundleIdentifier = "com.4d.4d" | head -n 1)
fi
fi
if [ -d "$dst" ]; then
dst=$dst/Contents/Components
if [ ! -d "$dst" ]; then
mkdir -p "$dst"
fi
if [ -d "$dst/$package.4dbase" ]; then
echo "🗑 Remove previous installation"
rm -Rf "$dst/$package.4dbase"
fi
echo "⏳ Install into $dst"
cp -Rf $src $dst/
echo "🧹 Clean temporary files"
rm -rf "$TMP"
echo "💡 Accept 'On Host Database Event' and restart your database. Then open http://localhost:8349"
else
echo "🛑 No 4D path. Component in $src" >&2
exit 1
fi