1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-27 14:12:09 +00:00
seirdy.one/scripts/compress.sh

24 lines
731 B
Bash
Raw Normal View History

#!/bin/sh
# takes three args:
# 1. output dir
# 2. "gzip" or "brotli"
# 3. ECT zopfli compression level
2023-11-26 23:54:48 +00:00
#shellcheck disable=SC3040 # This only sets pipefail if it's available and otherwise does nothing
set -o pipefail 2>/dev/null || true
set -e -u
2023-11-26 23:54:48 +00:00
dirname="$(dirname "$0")"
output_dir="$1"
format="$2"
2023-08-21 18:27:07 +00:00
alias find_compressible='find "$output_dir" -type f \( -name "*.html" -o -name "*.txt" -o -name "*.xml" -o -name "*.webmanifest" -o -name "*.*.svg" -o -name "*.json" \)'
if [ "$format" = "gzip" ]; then
2023-11-26 23:54:48 +00:00
# compression level should be the third argument
find_compressible | xargs -n1 sh "$dirname/ect-wrapper.sh" "${3-6}"
elif [ "$format" = "brotli" ]; then
find_compressible | xargs -n1 sh "$dirname/brotli-wrapper.sh"
fi