use a temporary directory for nginx configuration

This commit is contained in:
Daniel Micay 2021-11-25 18:31:43 -05:00
parent bbd8299148
commit 71c26f59eb
3 changed files with 7 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
nginx.conf.tmp nginx-tmp
nginx.conf.root.tmp nginx.conf.root.tmp
node_modules node_modules
static-tmp static-tmp

View File

@ -33,10 +33,10 @@ for server in ${servers[@]}; do
ssh $remote ln -snf $target /srv/grapheneos.org ssh $remote ln -snf $target /srv/grapheneos.org
ssh $remote sync /srv/grapheneos.org ssh $remote sync /srv/grapheneos.org
cp nginx.conf.tmp nginx.conf.root.tmp cp nginx-tmp/nginx.conf nginx.conf.root.tmp
sed -i "s|/srv/grapheneos.org|$target|" nginx.conf.root.tmp sed -i "s|/srv/grapheneos.org|$target|" nginx.conf.root.tmp
rsync -rptcv --chmod=D755,F644 --delete nginx.conf.root.tmp $remote:/etc/nginx/nginx.conf rsync -rptcv --chmod=D755,F644 --delete nginx.conf.root.tmp $remote:/etc/nginx/nginx.conf
rsync -rptcv --chmod=D755,F644 --delete nginx/snippets/ $remote:/etc/nginx/snippets rsync -rptcv --chmod=D755,F644 --delete nginx-tmp/snippets/ $remote:/etc/nginx/snippets
ssh $remote 'sync /etc/nginx/nginx.conf /etc/nginx/snippets/*' ssh $remote 'sync /etc/nginx/nginx.conf /etc/nginx/snippets/*'
ssh $remote nginx -s reload ssh $remote nginx -s reload

View File

@ -5,6 +5,9 @@ shopt -s dotglob extglob globstar
export PATH="$PWD/node_modules/.bin:$PATH" export PATH="$PWD/node_modules/.bin:$PATH"
rm -rf nginx-tmp
cp -a nginx nginx-tmp
rm -rf static-tmp rm -rf static-tmp
cp -a static static-tmp cp -a static static-tmp
rm -rf static-tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} rm -rf static-tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)}
@ -38,8 +41,7 @@ for file in static-tmp/**/*.css static-tmp/js/*.js static-tmp/mask-icon.svg; do
replace+=";s@{{path|/${file#*/}}}@/${dest#*/}@g" replace+=";s@{{path|/${file#*/}}}@/${dest#*/}@g"
done done
cp nginx/nginx.conf nginx.conf.tmp sed -i "$replace" static-tmp/**/*.html nginx-tmp/nginx.conf
sed -i "$replace" static-tmp/**/*.html nginx.conf.tmp
xmllint --noout static-tmp/**/*.html xmllint --noout static-tmp/**/*.html
validatornu --Werror --also-check-css --also-check-svg static-tmp/**/!(bimi).@(css|html|svg) validatornu --Werror --also-check-css --also-check-svg static-tmp/**/!(bimi).@(css|html|svg)