Skip to content

Commit 5f83571

Browse files
committed
feat: enhance installation script with detailed verification steps
- Add download source and target information to output - Implement checksum calculation for SHA256 and MD5 - Include file type detection and size verification - Improve executable format verification and output messages
1 parent e49fb33 commit 5f83571

File tree

1 file changed

+92
-17
lines changed

1 file changed

+92
-17
lines changed

scripts/install.sh

100644100755
Lines changed: 92 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,58 @@ download_with_progress() {
7575
local size
7676
size=$(get_file_size "$url")
7777

78+
# Show download information
79+
if [ -n "$size" ] && [ "$size" -gt 0 ]; then
80+
echo -e " ${BLUE}📥 Downloading Pingu ($(format_bytes "$size"))${NC}"
81+
echo -e " ${INFO} Expected size: ${GREEN}$(format_bytes "$size")${NC}"
82+
else
83+
echo -e " ${BLUE}📥 Downloading Pingu${NC}"
84+
echo -e " ${WARN} Size information not available"
85+
fi
86+
87+
# Show download details
88+
echo -e " ${INFO} Using $(command_exists curl && echo "curl" || echo "wget") for download"
89+
echo ""
90+
7891
if command_exists curl; then
79-
if [ -n "$size" ] && [ "$size" -gt 0 ]; then
80-
echo -e "${BLUE}📥 Downloading Pingu ($(format_bytes "$size"))${NC}"
81-
else
82-
echo -e "${BLUE}📥 Downloading Pingu${NC}"
92+
# Use curl with detailed progress
93+
echo -e " ${DIM}Download Progress:${NC}"
94+
if ! curl -L --progress-bar \
95+
--connect-timeout 30 \
96+
--max-time 600 \
97+
--retry 3 \
98+
--retry-delay 2 \
99+
--user-agent "Pingu-Installer/1.0" \
100+
"$url" -o "$output"; then
101+
return 1
83102
fi
84103

85-
# Use curl with progress bar
86-
curl -L --progress-bar "$url" -o "$output" || return 1
87-
88104
elif command_exists wget; then
89-
if [ -n "$size" ] && [ "$size" -gt 0 ]; then
90-
echo -e "${BLUE}📥 Downloading Pingu ($(format_bytes "$size"))${NC}"
91-
else
92-
echo -e "${BLUE}📥 Downloading Pingu${NC}"
105+
# Use wget with detailed progress
106+
echo -e " ${DIM}Download Progress:${NC}"
107+
if ! wget --show-progress \
108+
--progress=bar:force:noscroll \
109+
--timeout=30 \
110+
--tries=3 \
111+
--waitretry=2 \
112+
--user-agent="Pingu-Installer/1.0" \
113+
"$url" -O "$output"; then
114+
return 1
93115
fi
94116

95-
# Use wget with progress bar
96-
wget --show-progress -q "$url" -O "$output" || return 1
97-
98117
else
99118
error_exit "curl or wget is required to download Pingu"
100119
fi
120+
121+
# Verify download completed
122+
local actual_size
123+
actual_size=$(stat -f%z "$output" 2>/dev/null || stat -c%s "$output" 2>/dev/null || echo "0")
124+
125+
if [ -n "$size" ] && [ "$size" -gt 0 ] && [ "$actual_size" -ne "$size" ]; then
126+
echo -e " ${WARN} Size mismatch: expected $(format_bytes "$size"), got $(format_bytes "$actual_size")"
127+
fi
128+
129+
echo -e " ${CHECKMARK} Downloaded $(format_bytes "$actual_size")"
101130
}
102131

103132
# Function to detect package manager
@@ -256,29 +285,75 @@ cd "$TMP_DIR"
256285

257286
# Download binary with progress
258287
print_step "Downloading Pingu"
288+
echo -e " ${INFO} Source: ${DIM}${DOWNLOAD_URL}${NC}"
289+
echo -e " ${INFO} Target: ${DIM}${LOCAL_BINARY}${NC}"
290+
echo ""
291+
259292
if ! download_with_progress "$DOWNLOAD_URL" "$LOCAL_BINARY"; then
260293
rm -rf "$TMP_DIR"
261294
error_exit "Failed to download Pingu from $DOWNLOAD_URL"
262295
fi
263296
echo -e " ${CHECKMARK} Download completed successfully"
264297
echo ""
265298

266-
# Verify download
299+
print_step "Verifying Download"
300+
# Verify download exists
267301
if [ ! -f "$LOCAL_BINARY" ]; then
268302
rm -rf "$TMP_DIR"
269303
error_exit "Downloaded file not found"
270304
fi
271305

306+
# Get file information
272307
FILE_SIZE=$(stat -f%z "$LOCAL_BINARY" 2>/dev/null || stat -c%s "$LOCAL_BINARY" 2>/dev/null || echo "0")
273308
if [ "$FILE_SIZE" -eq 0 ]; then
274309
rm -rf "$TMP_DIR"
275310
error_exit "Downloaded file is empty"
276311
fi
277-
echo -e " ${CHECKMARK} File verified ($(format_bytes "$FILE_SIZE"))"
312+
313+
# Calculate checksums
314+
echo -e " ${INFO} Calculating checksums..."
315+
if command_exists sha256sum; then
316+
SHA256=$(sha256sum "$LOCAL_BINARY" | awk '{print $1}')
317+
echo -e " ${CHECKMARK} SHA256: ${DIM}${SHA256}${NC}"
318+
elif command_exists shasum; then
319+
SHA256=$(shasum -a 256 "$LOCAL_BINARY" | awk '{print $1}')
320+
echo -e " ${CHECKMARK} SHA256: ${DIM}${SHA256}${NC}"
321+
fi
322+
323+
if command_exists md5sum; then
324+
MD5=$(md5sum "$LOCAL_BINARY" | awk '{print $1}')
325+
echo -e " ${CHECKMARK} MD5: ${DIM}${MD5}${NC}"
326+
elif command_exists md5; then
327+
MD5=$(md5 -q "$LOCAL_BINARY")
328+
echo -e " ${CHECKMARK} MD5: ${DIM}${MD5}${NC}"
329+
fi
330+
331+
# File type detection
332+
if command_exists file; then
333+
FILE_TYPE=$(file "$LOCAL_BINARY")
334+
echo -e " ${CHECKMARK} File type: ${DIM}${FILE_TYPE}${NC}"
335+
fi
336+
337+
# File size verification
338+
echo -e " ${CHECKMARK} File size: ${GREEN}$(format_bytes "$FILE_SIZE")${NC}"
339+
340+
# Verify it's executable
341+
if file "$LOCAL_BINARY" | grep -q "executable"; then
342+
echo -e " ${CHECKMARK} Executable format verified"
343+
else
344+
echo -e " ${WARN} Warning: File may not be executable format"
345+
fi
278346

279347
# Make executable
280348
chmod +x "$LOCAL_BINARY"
281-
echo -e " ${CHECKMARK} Made executable"
349+
echo -e " ${CHECKMARK} Execute permissions set"
350+
351+
# Final verification
352+
if [ -x "$LOCAL_BINARY" ]; then
353+
echo -e " ${CHECKMARK} Binary is ready for installation"
354+
else
355+
error_exit "Failed to set execute permissions"
356+
fi
282357
echo ""
283358

284359
# Install to system

0 commit comments

Comments
 (0)