6363echo -e " ${YELLOW} Setting up for ${ENVIRONMENT} development...${NC} "
6464echo " "
6565
66+ # Detect OS and package manager
67+ detect_os () {
68+ if [[ -f /etc/os-release ]]; then
69+ . /etc/os-release
70+ OS=$ID
71+ OS_VERSION=$VERSION_ID
72+ elif [[ " $( uname) " == " Darwin" ]]; then
73+ OS=" macos"
74+ else
75+ OS=" unknown"
76+ fi
77+ }
78+
79+ detect_os
80+
6681# Common tools check
6782echo -e " ${YELLOW} Checking common tools...${NC} "
6883tools_missing=0
@@ -72,9 +87,9 @@ if command -v curl >/dev/null 2>&1; then
7287 echo -e " ${GREEN} ✓ curl found: $( curl --version | head -n1) ${NC} "
7388else
7489 echo -e " ${RED} ✗ curl not found - please install curl${NC} "
75- if [[ " $( uname ) " == " Darwin " ]]; then
90+ if [[ " $OS " == " macos " ]]; then
7691 echo " brew install curl"
77- elif [[ " $( uname ) " == " Linux " ]]; then
92+ elif [[ " $OS " == " debian " || " $OS " == " ubuntu " ]]; then
7893 echo " sudo apt-get install curl"
7994 fi
8095 tools_missing=1
@@ -85,9 +100,9 @@ if command -v jq >/dev/null 2>&1; then
85100 echo -e " ${GREEN} ✓ jq found: $( jq --version) ${NC} "
86101else
87102 echo -e " ${RED} ✗ jq not found - please install jq for JSON parsing${NC} "
88- if [[ " $( uname ) " == " Darwin " ]]; then
103+ if [[ " $OS " == " macos " ]]; then
89104 echo " brew install jq"
90- elif [[ " $( uname ) " == " Linux " ]]; then
105+ elif [[ " $OS " == " debian " || " $OS " == " ubuntu " ]]; then
91106 echo " sudo apt-get install jq"
92107 fi
93108 tools_missing=1
@@ -104,12 +119,11 @@ if [[ "$ENVIRONMENT" == "local" ]]; then
104119 echo -e " ${GREEN} ✓ nginx found: $CURRENT_VERSION ${NC} "
105120 else
106121 echo -e " ${RED} ✗ nginx not found - please install nginx${NC} "
107- if [[ " $( uname ) " == " Darwin " ]]; then
122+ if [[ " $OS " == " macos " ]]; then
108123 echo " brew install nginx"
109- elif [[ " $( uname) " == " Linux" ]]; then
110- echo " # Ubuntu/Debian:"
124+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
111125 echo " sudo apt-get install nginx"
112- echo " # CentOS/RHEL: "
126+ elif [[ " $OS " == " centos " || " $OS " == " rhel " || " $OS " == " fedora " ]] ; then
113127 echo " sudo yum install nginx"
114128 fi
115129 tools_missing=1
@@ -120,14 +134,10 @@ if [[ "$ENVIRONMENT" == "local" ]]; then
120134 echo -e " ${GREEN} ✓ node found: $( node --version) ${NC} "
121135 else
122136 echo -e " ${RED} ✗ node not found - please install Node.js for echo server${NC} "
123- if [[ " $( uname ) " == " Darwin " ]]; then
137+ if [[ " $OS " == " macos " ]]; then
124138 echo " brew install node"
125- elif [[ " $( uname) " == " Linux" ]]; then
126- echo " # Ubuntu/Debian:"
139+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
127140 echo " sudo apt-get install nodejs npm"
128- echo " # Or use NodeSource:"
129- echo " curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -"
130- echo " sudo apt-get install -y nodejs"
131141 fi
132142 tools_missing=1
133143 fi
@@ -150,6 +160,152 @@ if [[ "$ENVIRONMENT" == "local" ]]; then
150160 tools_missing=1
151161 fi
152162
163+ echo " "
164+ echo -e " ${YELLOW} Checking Rust build dependencies...${NC} "
165+
166+ # Check clang/LLVM (required for bindgen)
167+ if command -v clang > /dev/null 2>&1 ; then
168+ echo -e " ${GREEN} ✓ clang found: $( clang --version | head -n1) ${NC} "
169+ else
170+ echo -e " ${RED} ✗ clang not found - required for Rust bindgen${NC} "
171+ if [[ " $OS " == " macos" ]]; then
172+ echo " xcode-select --install"
173+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
174+ echo " sudo apt-get install clang"
175+ elif [[ " $OS " == " alpine" ]]; then
176+ echo " apk add clang-dev"
177+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
178+ echo " sudo dnf install clang"
179+ fi
180+ tools_missing=1
181+ fi
182+
183+ # Check PCRE2 development files
184+ pcre2_found=false
185+ if [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
186+ if dpkg -l | grep -q libpcre2-dev; then
187+ echo -e " ${GREEN} ✓ libpcre2-dev found${NC} "
188+ pcre2_found=true
189+ fi
190+ elif [[ " $OS " == " macos" ]]; then
191+ if brew list pcre2 & > /dev/null; then
192+ echo -e " ${GREEN} ✓ pcre2 found${NC} "
193+ pcre2_found=true
194+ fi
195+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
196+ if rpm -q pcre2-devel & > /dev/null; then
197+ echo -e " ${GREEN} ✓ pcre2-devel found${NC} "
198+ pcre2_found=true
199+ fi
200+ fi
201+
202+ if [[ " $pcre2_found " == " false" ]]; then
203+ echo -e " ${RED} ✗ PCRE2 development files not found - required for nginx module build${NC} "
204+ if [[ " $OS " == " macos" ]]; then
205+ echo " brew install pcre2"
206+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
207+ echo " sudo apt-get install libpcre2-dev"
208+ elif [[ " $OS " == " alpine" ]]; then
209+ echo " apk add pcre2-dev"
210+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
211+ echo " sudo dnf install pcre2-devel"
212+ fi
213+ tools_missing=1
214+ fi
215+
216+ # Check OpenSSL development files
217+ openssl_found=false
218+ if [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
219+ if dpkg -l | grep -q libssl-dev; then
220+ echo -e " ${GREEN} ✓ libssl-dev found${NC} "
221+ openssl_found=true
222+ fi
223+ elif [[ " $OS " == " macos" ]]; then
224+ if brew list openssl & > /dev/null; then
225+ echo -e " ${GREEN} ✓ openssl found${NC} "
226+ openssl_found=true
227+ fi
228+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
229+ if rpm -q openssl-devel & > /dev/null; then
230+ echo -e " ${GREEN} ✓ openssl-devel found${NC} "
231+ openssl_found=true
232+ fi
233+ fi
234+
235+ if [[ " $openssl_found " == " false" ]]; then
236+ echo -e " ${RED} ✗ OpenSSL development files not found - required for nginx module build${NC} "
237+ if [[ " $OS " == " macos" ]]; then
238+ echo " brew install openssl"
239+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
240+ echo " sudo apt-get install libssl-dev"
241+ elif [[ " $OS " == " alpine" ]]; then
242+ echo " apk add openssl-dev"
243+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
244+ echo " sudo dnf install openssl-devel"
245+ fi
246+ tools_missing=1
247+ fi
248+
249+ # Check zlib development files
250+ zlib_found=false
251+ if [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
252+ if dpkg -l | grep -q zlib1g-dev; then
253+ echo -e " ${GREEN} ✓ zlib1g-dev found${NC} "
254+ zlib_found=true
255+ fi
256+ elif [[ " $OS " == " macos" ]]; then
257+ if brew list zlib & > /dev/null; then
258+ echo -e " ${GREEN} ✓ zlib found${NC} "
259+ zlib_found=true
260+ fi
261+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
262+ if rpm -q zlib-devel & > /dev/null; then
263+ echo -e " ${GREEN} ✓ zlib-devel found${NC} "
264+ zlib_found=true
265+ fi
266+ fi
267+
268+ if [[ " $zlib_found " == " false" ]]; then
269+ echo -e " ${RED} ✗ zlib development files not found - required for nginx gzip module${NC} "
270+ if [[ " $OS " == " macos" ]]; then
271+ echo " brew install zlib"
272+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
273+ echo " sudo apt-get install zlib1g-dev"
274+ elif [[ " $OS " == " alpine" ]]; then
275+ echo " apk add zlib-dev"
276+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
277+ echo " sudo dnf install zlib-devel"
278+ fi
279+ tools_missing=1
280+ fi
281+
282+ # Check make
283+ if command -v make > /dev/null 2>&1 ; then
284+ echo -e " ${GREEN} ✓ make found: $( make --version | head -n1) ${NC} "
285+ else
286+ echo -e " ${RED} ✗ make not found - required for nginx module build${NC} "
287+ if [[ " $OS " == " macos" ]]; then
288+ echo " xcode-select --install"
289+ elif [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
290+ echo " sudo apt-get install build-essential"
291+ elif [[ " $OS " == " alpine" ]]; then
292+ echo " apk add make"
293+ elif [[ " $OS " == " centos" || " $OS " == " rhel" || " $OS " == " fedora" ]]; then
294+ echo " sudo dnf install make"
295+ fi
296+ tools_missing=1
297+ fi
298+
299+ # Optional: Check pkg-config (helpful for finding libraries)
300+ if command -v pkg-config > /dev/null 2>&1 ; then
301+ echo -e " ${GREEN} ✓ pkg-config found: $( pkg-config --version) ${NC} "
302+ else
303+ echo -e " ${YELLOW} ⚠ pkg-config not found - optional but recommended${NC} "
304+ if [[ " $OS " == " debian" || " $OS " == " ubuntu" ]]; then
305+ echo " sudo apt-get install pkg-config"
306+ fi
307+ fi
308+
153309elif [[ " $ENVIRONMENT " == " docker" ]]; then
154310 echo -e " ${YELLOW} Checking Docker development requirements...${NC} "
155311
@@ -235,6 +391,15 @@ else
235391 echo -e " ${RED} ✗ Some required tools are missing for ${ENVIRONMENT} development${NC} "
236392 echo " Please install the missing tools and run this script again."
237393 echo " "
394+
395+ # Provide a quick install command for Debian/Ubuntu
396+ if [[ " $ENVIRONMENT " == " local" && (" $OS " == " debian" || " $OS " == " ubuntu" ) ]]; then
397+ echo -e " ${YELLOW} Quick install for Debian/Ubuntu:${NC} "
398+ echo " sudo apt-get update"
399+ echo " sudo apt-get install -y clang libpcre2-dev libssl-dev zlib1g-dev build-essential pkg-config"
400+ echo " "
401+ fi
402+
238403 echo " You can also try the other environment:"
239404 if [[ " $ENVIRONMENT " == " local" ]]; then
240405 echo " $0 --docker # Setup for Docker-based testing"
243408 fi
244409fi
245410
246- exit $tools_missing
411+ exit $tools_missing
0 commit comments