matrix.grapheneos.org/process-static
2021-12-13 11:44:00 -05:00

31 lines
761 B
Bash
Executable File

#!/bin/bash
set -o errexit -o nounset -o pipefail
shopt -s dotglob extglob globstar
export PATH="$PWD/node_modules/.bin:$PATH"
rm -rf nginx-tmp
cp -a nginx nginx-tmp
rm -rf static-tmp
cp -a /usr/share/webapps/element static-tmp
cp --remove-destination webapps/element/config.json static-tmp/config.json
# work around https://bugs.archlinux.org/task/72968
find static-tmp -name '*.js' -exec sed -i "s/!!UNSET!!/$(cat static-tmp/version | tr -d '\n')/g" {} +
brotli_k() {
brotli -k "$@"
}
export -f brotli_k
zopfli_preserve_time() {
zopfli "$1"
touch -r "$1" "$1.gz"
}
export -f zopfli_preserve_time
find static-tmp -regex '.+\.\(css\|html\|ico\|js\|json\|map\|svg\|txt\|wasm\|xml\)' |
parallel -q ::: brotli_k zopfli_preserve_time :::: -