-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
71 lines (62 loc) · 2.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
RED=$'\e[0;31m'
GREEN=$'\e[0;32m'
YELLOW=$'\e[0;33m'
NC=$'\e[0m' # No Color
PYTHON_EXECUTABLE="${PYTHON_EXECUTABLE:=}"
INSTALL_PY_URL="${INSTALL_PY_URL:=}"
INSTALL_PY_PATH="${INSTALL_PY_PATH:=}"
if ! command -v git &>/dev/null; then
echo "${RED}Please install git${NC}"
exit 1
fi
main() {
if [ "$PYTHON_EXECUTABLE" = "" ]; then
if ! command -v which &>/dev/null; then
echo "${RED}Please install python or provide python path:"
echo "PYTHON_EXECUTABLE=<path> install.sh"
echo "Please install which${NC}"
exit 1
fi
if command -v python3 &>/dev/null; then
PYTHON_EXECUTABLE="$(which python3)"
elif command -v python2 &>/dev/null; then
PYTHON_EXECUTABLE="$(which python2)"
elif command -v python &>/dev/null; then
PYTHON_EXECUTABLE="$(which python)"
else
echo "${RED}Please install python or provide python path:"
echo "PYTHON_EXECUTABLE=<path> install.sh${NC}"
exit 1
fi
echo "${YELLOW}Using Python: $PYTHON_EXECUTABLE ${NC}"
else
echo "${GREEN}Using Python: $PYTHON_EXECUTABLE ${NC}"
fi
if [ "$INSTALL_PY_PATH" != "" ]; then
# If a local installer script is given, then use it directly
"$PYTHON_EXECUTABLE" "$INSTALL_PY_PATH" "$@"
exit 0
fi
if [ "$INSTALL_PY_URL" = "" ]; then
INSTALL_PY_URL="https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.py"
fi
if command -v curl &>/dev/null; then
if curl --output /dev/null --silent --head --fail "$INSTALL_PY_URL"; then
curl -sSf "$INSTALL_PY_URL" | "$PYTHON_EXECUTABLE" - "$@"
else
echo "${RED}$INSTALL_PY_URL not reachable${NC}"
fi
elif command -v wget &>/dev/null; then
if wget -q --method=HEAD "$INSTALL_PY_URL"; then
wget -qO- "$INSTALL_PY_URL" | "$PYTHON_EXECUTABLE" - "$@"
else
echo "${RED}$INSTALL_PY_URL not reachable{NC}"
fi
else
echo "${RED}curl or wget could not be found${NC}"
exit 1
fi
}
main "$@"