matrix.grapheneos.org/process-static
Daniel Micay 1ad4819d8a switch to gixy-ng
Explicitly keep the previous add_header_redefinition behavior to work
around the fact that setting Cross-Origin-Resource-Policy is delegated
to synapse even though we set it at the top-level for non-synapse. We
could change the approach to working around this later.
2025-08-17 05:40:31 -04:00

30 lines
744 B
Bash
Executable file

#!/bin/bash
set -o errexit -o nounset -o pipefail
shopt -s dotglob extglob globstar
source venv/bin/activate
if [[ $# -eq 1 ]]; then
fd=$1
else
touch lock
exec {fd}< lock
fi
if ! flock -n $fd; then
echo already processing/deploying static files >&2
exit 1
fi
rm -rf nginx-tmp
cp -a nginx nginx-tmp
gixy --add-header-redefinition-headers x-frame-options,x-content-type-options,x-xss-protection,content-security-policy,cache-control nginx-tmp/nginx.conf
rm -rf static-tmp
cp -a /usr/share/webapps/element static-tmp
cp --remove-destination webapps/element/config.json static-tmp/config.json
find static-tmp -regex '.+\.\(css\|html\|ico\|js\|json\|map\|svg\|txt\|wasm\|xml\)' |
parallel -q ::: brotli zopfli :::: -