From 7329d664bb4dd4ad5b0aa9cf0cf9caef410199bf Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 8 Jul 2021 04:33:12 -0400 Subject: rename scripts --- .github/workflows/static.yml | 8 ++++---- deploy-static | 34 +++++++++++++++++++++++++++++++++ deploy_static | 34 --------------------------------- process-static | 45 ++++++++++++++++++++++++++++++++++++++++++++ process_static | 45 -------------------------------------------- validate-static | 19 +++++++++++++++++++ validate_static | 19 ------------------- 7 files changed, 102 insertions(+), 102 deletions(-) create mode 100755 deploy-static delete mode 100755 deploy_static create mode 100755 process-static delete mode 100755 process_static create mode 100755 validate-static delete mode 100755 validate_static diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 424cd69d..11c00acb 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -39,14 +39,14 @@ jobs: - name: Download validatornu # There isn't a package with a `validatornu` command in Ubuntu, so download the validator - # from the GitHub releases and change the validate_static script later to use it. + # from the GitHub releases and change the validate-static script later to use it. run: wget https://github.com/validator/validator/releases/download/${{ env.VALIDATOR_VERSION }}/vnu.linux.zip && unzip vnu.linux.zip if: steps.validator-cache.outputs.cache-hit != 'true' - - run: sed -i 's+validatornu+vnu-runtime-image/bin/vnu+g' validate_static + - run: sed -i 's+validatornu+vnu-runtime-image/bin/vnu+g' validate-static - name: validate static - run: ./validate_static + run: ./validate-static - name: process static - run: ./process_static + run: ./process-static diff --git a/deploy-static b/deploy-static new file mode 100755 index 00000000..a48a4b9c --- /dev/null +++ b/deploy-static @@ -0,0 +1,34 @@ +#!/bin/bash + +set -o errexit -o nounset -o pipefail + +./validate-static +./process-static + +remote=root@grapheneos.org +active=$(ssh $remote readlink /srv/grapheneos.org) + +if [[ $active = /srv/grapheneos.org_a ]]; then + target=/srv/grapheneos.org_b +else + target=/srv/grapheneos.org_a +fi + +echo active is $active +echo target is $target +echo + +ssh $remote rm -rf $target +ssh $remote cp -a $active $target +rsync -rpcv --chmod=D755,F644 --delete static_tmp/ $remote:$target +ssh $remote sync -f $target +ssh $remote ln -snf $target /srv/grapheneos.org +ssh $remote sync . + +sed -i "s|/srv/grapheneos.org|$target|" nginx.conf.tmp +rsync -rpcv --chmod=D755,F644 --delete nginx.conf.tmp $remote:/etc/nginx/nginx.conf +ssh $remote sync -f /etc/nginx/nginx.conf +ssh $remote nginx -s reload + +echo +echo active is now $target diff --git a/deploy_static b/deploy_static deleted file mode 100755 index 18571959..00000000 --- a/deploy_static +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -o errexit -o nounset -o pipefail - -./validate_static -./process_static - -remote=root@grapheneos.org -active=$(ssh $remote readlink /srv/grapheneos.org) - -if [[ $active = /srv/grapheneos.org_a ]]; then - target=/srv/grapheneos.org_b -else - target=/srv/grapheneos.org_a -fi - -echo active is $active -echo target is $target -echo - -ssh $remote rm -rf $target -ssh $remote cp -a $active $target -rsync -rpcv --chmod=D755,F644 --delete static_tmp/ $remote:$target -ssh $remote sync -f $target -ssh $remote ln -snf $target /srv/grapheneos.org -ssh $remote sync . - -sed -i "s|/srv/grapheneos.org|$target|" nginx.conf.tmp -rsync -rpcv --chmod=D755,F644 --delete nginx.conf.tmp $remote:/etc/nginx/nginx.conf -ssh $remote sync -f /etc/nginx/nginx.conf -ssh $remote nginx -s reload - -echo -echo active is now $target diff --git a/process-static b/process-static new file mode 100755 index 00000000..25917aa4 --- /dev/null +++ b/process-static @@ -0,0 +1,45 @@ +#!/bin/bash + +set -o errexit -o nounset -o pipefail +shopt -s dotglob extglob globstar + +export PATH="$PWD/node_modules/.bin:$PATH" + +rm -rf static_tmp +cp -a static static_tmp +rm -rf static_tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} +mv static_tmp/js/fastboot/dist static_tmp/js/fastboot/v1.0.9 + +for file in static_tmp/**/*.@(json|webmanifest); do + json_reformat -m < "$file" | sponge "$file" +done + +find static_tmp -name '*.css' -exec csso {} -o {} \; +find static_tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \; + +replace="" +for file in static_tmp/**/*.css static_tmp/js/*.js static_tmp/mask-icon.svg; do + hash=$(sha256sum "$file" | head -c 8) + dest="$(dirname $file)/$hash.$(basename $file)" + mv "$file" "$dest" + replace+=";s|/${file#*/}|/${dest#*/}|g" +done + +cp nginx/nginx.conf nginx.conf.tmp +sed -i "$replace" static_tmp/**/*.html nginx.conf.tmp + +find static_tmp -name '*.html' -exec html-minifier --collapse-whitespace \ + --process-scripts "application/ld+json" --collapse-boolean-attributes \ + --remove-attribute-quotes --remove-comments --remove-empty-attributes \ + --remove-redundant-attributes --remove-script-type-attributes \ + --remove-style-link-type-attributes --sort-attributes --sort-class-name {} -o {} \; + +./generate_feed.py + +for file in static_tmp/**/*.@(atom|xml); do + xmllint --noblanks "$file" --output "$file" +done + +find static_tmp -regex '.+\.\(atom\|css\|html\|ico\|js\|json\|mjs\|pdf\|svg\|txt\|webmanifest\|xml\)' \ + -exec zopfli {} \; -exec touch -r {} {}.gz \; \ + -exec brotli -k {} \; diff --git a/process_static b/process_static deleted file mode 100755 index 25917aa4..00000000 --- a/process_static +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -set -o errexit -o nounset -o pipefail -shopt -s dotglob extglob globstar - -export PATH="$PWD/node_modules/.bin:$PATH" - -rm -rf static_tmp -cp -a static static_tmp -rm -rf static_tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} -mv static_tmp/js/fastboot/dist static_tmp/js/fastboot/v1.0.9 - -for file in static_tmp/**/*.@(json|webmanifest); do - json_reformat -m < "$file" | sponge "$file" -done - -find static_tmp -name '*.css' -exec csso {} -o {} \; -find static_tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \; - -replace="" -for file in static_tmp/**/*.css static_tmp/js/*.js static_tmp/mask-icon.svg; do - hash=$(sha256sum "$file" | head -c 8) - dest="$(dirname $file)/$hash.$(basename $file)" - mv "$file" "$dest" - replace+=";s|/${file#*/}|/${dest#*/}|g" -done - -cp nginx/nginx.conf nginx.conf.tmp -sed -i "$replace" static_tmp/**/*.html nginx.conf.tmp - -find static_tmp -name '*.html' -exec html-minifier --collapse-whitespace \ - --process-scripts "application/ld+json" --collapse-boolean-attributes \ - --remove-attribute-quotes --remove-comments --remove-empty-attributes \ - --remove-redundant-attributes --remove-script-type-attributes \ - --remove-style-link-type-attributes --sort-attributes --sort-class-name {} -o {} \; - -./generate_feed.py - -for file in static_tmp/**/*.@(atom|xml); do - xmllint --noblanks "$file" --output "$file" -done - -find static_tmp -regex '.+\.\(atom\|css\|html\|ico\|js\|json\|mjs\|pdf\|svg\|txt\|webmanifest\|xml\)' \ - -exec zopfli {} \; -exec touch -r {} {}.gz \; \ - -exec brotli -k {} \; diff --git a/validate-static b/validate-static new file mode 100755 index 00000000..e1b08025 --- /dev/null +++ b/validate-static @@ -0,0 +1,19 @@ +#!/bin/bash + +set -o errexit -o nounset -o pipefail +shopt -s dotglob extglob globstar + +export PATH="$PWD/node_modules/.bin:$PATH" + +rm -rf static_tmp +cp -a static static_tmp +rm -rf static_tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} + +for file in static_tmp/**/*.@(json|webmanifest); do + json_verify < "$file" >/dev/null +done + +xmllint --noout static_tmp/**/*.@(html|svg|xml) +eslint static_tmp/**/!(fastboot.min.m|z-worker-pako.|pako_inflate.min.|)js +stylelint static_tmp/**/*.css +validatornu --Werror --also-check-css --also-check-svg static_tmp/**/*.@(css|html|svg) diff --git a/validate_static b/validate_static deleted file mode 100755 index e1b08025..00000000 --- a/validate_static +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -o errexit -o nounset -o pipefail -shopt -s dotglob extglob globstar - -export PATH="$PWD/node_modules/.bin:$PATH" - -rm -rf static_tmp -cp -a static static_tmp -rm -rf static_tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} - -for file in static_tmp/**/*.@(json|webmanifest); do - json_verify < "$file" >/dev/null -done - -xmllint --noout static_tmp/**/*.@(html|svg|xml) -eslint static_tmp/**/!(fastboot.min.m|z-worker-pako.|pako_inflate.min.|)js -stylelint static_tmp/**/*.css -validatornu --Werror --also-check-css --also-check-svg static_tmp/**/*.@(css|html|svg) -- cgit v1.3.1