-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepiviz_from_atom.sh
executable file
·147 lines (129 loc) · 3.44 KB
/
epiviz_from_atom.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
#
# sourced from atom - github.com/atom/atom
#
#
if [ "$(uname)" == 'Darwin' ]; then
OS='Mac'
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
OS='Linux'
else
echo "Your platform ($(uname -a)) is not supported."
exit 1
fi
if [ "$(basename $0)" == 'epiviz-beta' ]; then
BETA_VERSION=true
else
BETA_VERSION=
fi
export EPIVIZ_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true
while getopts ":wtfvh-:" opt; do
case "$opt" in
-)
case "${OPTARG}" in
wait)
WAIT=1
;;
help|version)
REDIRECT_STDERR=1
EXPECT_OUTPUT=1
;;
foreground|benchmark|benchmark-test|test)
EXPECT_OUTPUT=1
;;
esac
;;
w)
WAIT=1
;;
h|v)
REDIRECT_STDERR=1
EXPECT_OUTPUT=1
;;
f|t)
EXPECT_OUTPUT=1
;;
esac
done
if [ $REDIRECT_STDERR ]; then
exec 2> /dev/null
fi
if [ $EXPECT_OUTPUT ]; then
export ELECTRON_ENABLE_LOGGING=1
fi
if [ $OS == 'Mac' ]; then
if [ -L "$0" ]; then
SCRIPT="$(readlink "$0")"
else
SCRIPT="$0"
fi
EPIVIZ_APP="Epiviz.app"
if [ "$EPIVIZ_APP" == . ]; then
unset EPIVIZ_APP
else
EPIVIZ_PATH="$(dirname "$EPIVIZ_APP")"
EPIVIZ_APP_NAME="$(basename "$EPIVIZ_APP")"
fi
if [ -n "$BETA_VERSION" ]; then
EPIVIZ_EXECUTABLE_NAME="Epiviz Beta"
else
EPIVIZ_EXECUTABLE_NAME="Epiviz"
fi
if [ -z "${EPIVIZ_PATH}" ]; then
# If EPIVIZ_PATH isn't set, check /Applications and then ~/Applications for EPIVIZ.app
if [ -x "/Applications/$EPIVIZ_APP_NAME" ]; then
EPIVIZ_PATH="/Applications"
elif [ -x "$HOME/Applications/$EPIVIZ_APP_NAME" ]; then
EPIVIZ_PATH="$HOME/Applications"
else
# We haven't found an EPIVIZ.app, use spotlight to search for EPIVIZ
EPIVIZ_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'org.epiviz.epiviz'" | grep -v ShipIt | head -1 | xargs -0 dirname)"
# Exit if EPIVIZ can't be found
if [ ! -x "$EPIVIZ_PATH/$EPIVIZ_APP_NAME" ]; then
echo "Cannot locate ${EPIVIZ_APP_NAME}, it is usually located in /Applications. Set the EPIVIZ_PATH environment variable to the directory containing ${EPIVIZ_APP_NAME}."
exit 1
fi
fi
fi
if [ $EXPECT_OUTPUT ]; then
"$EPIVIZ_PATH/$EPIVIZ_APP_NAME/Contents/MacOS/$EPIVIZ_EXECUTABLE_NAME" --executed-from="$(pwd)" --pid=$$ "$@"
exit $?
else
open -a "$EPIVIZ_PATH/$EPIVIZ_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ --path-environment="$PATH" "$@"
fi
elif [ $OS == 'Linux' ]; then
SCRIPT=$(readlink -f "$0")
USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..)
if [ -n "$BETA_VERSION" ]; then
EPIVIZ_PATH="$USR_DIRECTORY/share/epiviz-beta/epiviz"
else
EPIVIZ_PATH="$USR_DIRECTORY/share/epiviz/epiviz"
fi
EPIVIZ_HOME="${EPIVIZ_HOME:-$HOME/.epiviz}"
mkdir -p "$EPIVIZ_HOME"
: ${TMPDIR:=/tmp}
[ -x "$EPIVIZ_PATH" ] || EPIVIZ_PATH="$TMPDIR/epiviz-build/Epiviz/epiviz"
if [ $EXPECT_OUTPUT ]; then
"$EPIVIZ_PATH" --executed-from="$(pwd)" --pid=$$ "$@"
exit $?
else
(
nohup "$EPIVIZ_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$EPIVIZ_HOME/nohup.out" 2>&1
if [ $? -ne 0 ]; then
cat "$EPIVIZ_HOME/nohup.out"
exit $?
fi
) &
fi
fi
# Exits this process when EPIVIZ is used as $EDITOR
on_die() {
exit 0
}
trap 'on_die' SIGQUIT SIGTERM
# If the wait flag is set, don't exit this process until EPIVIZ tells it to.
if [ $WAIT ]; then
while true; do
sleep 1
done
fi