fix(droplet): Use extension-based file detection for OpenWrt
The 'file' command is not available on OpenWrt. Replaced mime-type detection with extension parsing (.html, .htm, .zip). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1598ee9391
commit
f8d9c5ee70
@ -74,9 +74,10 @@ cmd_publish() {
|
|||||||
|
|
||||||
log_info "Publishing: $file as $vhost"
|
log_info "Publishing: $file as $vhost"
|
||||||
|
|
||||||
# Extract if ZIP
|
# Detect file type by extension (file command not available on OpenWrt)
|
||||||
local content_type=$(file -b --mime-type "$file")
|
local file_ext=$(echo "$file" | sed 's/.*\.//' | tr '[:upper:]' '[:lower:]')
|
||||||
if echo "$content_type" | grep -q "zip"; then
|
|
||||||
|
if [ "$file_ext" = "zip" ]; then
|
||||||
log_info "Extracting ZIP..."
|
log_info "Extracting ZIP..."
|
||||||
unzip -q "$file" -d "$tmp_dir" || { log_error "Failed to extract ZIP"; rm -rf "$tmp_dir"; return 1; }
|
unzip -q "$file" -d "$tmp_dir" || { log_error "Failed to extract ZIP"; rm -rf "$tmp_dir"; return 1; }
|
||||||
|
|
||||||
@ -86,11 +87,11 @@ cmd_publish() {
|
|||||||
mv "$nested"/* "$tmp_dir/" 2>/dev/null
|
mv "$nested"/* "$tmp_dir/" 2>/dev/null
|
||||||
rmdir "$nested" 2>/dev/null
|
rmdir "$nested" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
elif echo "$content_type" | grep -qE "html|text"; then
|
elif [ "$file_ext" = "html" ] || [ "$file_ext" = "htm" ]; then
|
||||||
# Single HTML file
|
# Single HTML file
|
||||||
cp "$file" "$tmp_dir/index.html"
|
cp "$file" "$tmp_dir/index.html"
|
||||||
else
|
else
|
||||||
log_error "Unsupported file type: $content_type"
|
log_error "Unsupported file type: .$file_ext (expected .html, .htm, or .zip)"
|
||||||
rm -rf "$tmp_dir"
|
rm -rf "$tmp_dir"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user