-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprerequisite-check.sh
executable file
·106 lines (90 loc) · 3.45 KB
/
prerequisite-check.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
#!/bin/bash
# Set colors using tput
if [ "${CI:-false}" = "true" ]; then
# disable colors in CI
red=""
green=""
yellow=""
cyan=""
bold=""
reset=""
else
red=$(tput -T xterm setaf 1)
green=$(tput -T xterm setaf 2)
yellow=$(tput -T xterm setaf 3)
cyan=$(tput -T xterm setaf 6)
bold=$(tput -T xterm bold)
reset=$(tput -T xterm sgr0)
fi
echo "${cyan}Galileo Prerequisite Check...${reset}"
echo ""
# don't print the network node hostname
SYS_INFO=$(uname -srvmpio)
echo "${cyan}system: $SYS_INFO${reset}"
# We need pnpm dlx for semver check
if ! [ -x "$(command -v pnpm)" ]; then
echo "${red}pnpm: Not installed ${reset}"
echo "${yellow}Required >=8.x; Install https://pnpm.io/installation ${rest}"
exit 1
fi
check() {
local cmd="$1"
local version_cmd="$2"
local range="$3"
local recommendation="$4"
local print="$recommendation"
if ! [ -x "$(command -v $cmd)" ]; then
[ -n "$print" ] && echo "${red}$cmd: Not installed - required $range ${reset}"
[ -n "$print" ] && echo "${yellow}$recommendation ${reset}"
return 1
fi
local version="$($version_cmd)"
local valid_version=$(pnpm --silent dlx semver --coerce --range "$range" "$version")
[ -n "$print" ] && echo "${cyan}$cmd: $version ${reset}"
if [ -z "$valid_version" ]; then
[ -n "$print" ] && echo "${red}$cmd: required $range; found $version ${reset}"
[ -n "$print" ] && echo "${yellow}$recommendation ${reset}"
return 1
fi
return 0
}
check "pnpm" "pnpm --version" ">=8" \
"Recommendation: Install PNPM 8.6+. See https://pnpm.io/installation"
PNPM_PASS=$?
check "node" "node --version" ">=18" \
"Recommendation: Use nvm to install NodeJS 18+. See https://github.com/nvm-sh/nvm"
NODEJS_PASS=$?
check "python" "python --version" ">=3.10 <4" \
"Recommendation: Use pyenv to install Python 3.11+. See https://github.com/pyenv/pyenv"
PYTHON_PASS=$?
check "poetry" "poetry --version" ">=1.5 <2" \
"Recommendation: Use poetry to install Python 3.11+. See https://python-poetry.org/docs/#installation"
POETRY_PASS=$?
check "docker" "docker --version" ">=20.10" \
"Recommendation: Use Docker Desktop to install Docker 20+. See https://docs.docker.com/desktop/"
DOCKER_PASS=$?
check "java" "java --version | head -n 1" ">=17" \
"Recommendation: Use Amazon Corretto 17. See https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html"
JAVA_PASS=$?
check "aws" "aws --version" ">=2.13.23 <3" \
"Recommendation: AWS CLI v2 is required. See https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html"
AWS_PASS=$?
# Apple arm64 warnings
if [ "$(uname -s)" = "Darwin" ]; then
if [ "$(uname -m)" = "arm64" ]; then
check "python" "python --version" "3.10"
if [ $? != 0 ]; then
echo ""
echo "${yellow}[Apple Chip] Python3.10 might be required for some python packages on Apple arm64 chips - if you see errors during build please ensure python 3.10 is installed ${reset}"
echo "${yellow}Recommend using pyenv for multiple python version support. See https://github.com/pyenv/pyenv ${reset}"
echo "${yellow}See https://github.com/comfyanonymous/ComfyUI/issues/1164#issuecomment-1670798956 ${reset}"
fi
fi
fi
echo ""
if [ $PNPM_PASS != 0 ] || [ $NODEJS_PASS != 0 ] || [ $PYTHON_PASS != 0 ] || [ $POETRY_PASS != 0 ] || [ $DOCKER_PASS != 0 ] || [ $JAVA_PASS != 0 ] || [ $AWS_PASS != 0 ]; then
echo "${bold}${red}Prerequisite check failed ${reset}"
exit 1
else
echo "${bold}${green}Prerequisite check passed ${reset}"
fi