diff options
Diffstat (limited to 'recipes-core/lighttpd/lighttpd/lighttpd_custom_images_setup')
-rw-r--r-- | recipes-core/lighttpd/lighttpd/lighttpd_custom_images_setup | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/recipes-core/lighttpd/lighttpd/lighttpd_custom_images_setup b/recipes-core/lighttpd/lighttpd/lighttpd_custom_images_setup deleted file mode 100644 index ecd5f46..0000000 --- a/recipes-core/lighttpd/lighttpd/lighttpd_custom_images_setup +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# Detects mime types for UI Customization images and generates according Lighttpd config fragment - -CONFIG_PATH="/var/run/config/lighttpd_custom_images.conf" -IMAGE_PATH="/var/www/static/images/" -MAGIC_DB_PATH="/usr/share/misc/magic-images.mgc" -shopt -s nullglob - -echoerr() { - echo "$@" 1>&2 -} - -generate_mime_assign() { - local IMAGE="$1" - local OUTPUT=$(file -ib "$IMAGE" --magic-file "$MAGIC_DB_PATH") - local CONTENT_TYPE - - if [ "$?" -ne "0" ] || [[ "$OUTPUT" == "" ]] || [[ "$OUTPUT" == *"cannot open"* ]]; then - echoerr "Failed to run file(1): ${?}; ${OUTPUT}" - return 1 - fi - - CONTENT_TYPE="$OUTPUT" - cat <<END -\$HTTP["url"] =~ "/static/images/$IMAGE" { - mimetype.assign = ("" => "$CONTENT_TYPE") - } -END -} - -process_files() { - local INDENT=" " - local ELSE_STRING="" - local FRAGMENT - - for IMAGE in custom_*; do - INDENT=" " - - FRAGMENT=$(generate_mime_assign $IMAGE) - if [ "$?" -eq "0" ]; then - echo "${INDENT}${ELSE_STRING}${FRAGMENT}" >> "$CONFIG_PATH" - ELSE_STRING="else " - fi - done -} - -echo "Generating $CONFIG_PATH" - -# truncate and write head -cat > "$CONFIG_PATH" <<END -\$HTTP["url"] =~ "/static/images/custom_" { -END - -cd "$IMAGE_PATH" && process_files - -# write tail (closing brace) -echo "}" >> "$CONFIG_PATH" |