Commit 3d70b84f authored by Vitaly Lipatov's avatar Vitaly Lipatov

add azbyka_update_fallback.sh (eterbug #11957)

parent 06690621
#!/bin/sh
TEMPL=/etc/nginx/include/static-fallback.conf.TEMPLATE
TARG=/etc/nginx/include/static-fallback-
fatal()
{
echo "Fatal: $@"
exit 1
}
# new file -> old file
rewrite_if_changed()
{
local NEWFILE="$1" OLDFILE="$2"
if [ -r $OLDFILE ] ; then
if diff -u $OLDFILE $NEWFILE ; then
echo "$OLDFILE is not changed"
rm -f $NEWFILE
else
mv -f $NEWFILE $OLDFILE
fi
else
mv -f $NEWFILE $OLDFILE
fi
}
gen_static_fallback()
{
local f="$1"
local of=$TARG$f.conf
local otf=$TARG$f.conf.tmp
echo
echo "generate $otf"
cat $TEMPL | sed -e "s|@fallback|@fallback-$f|g" >$otf
# TODO: merge with rewrite_if_changed
[ -r "$of" ] || { echo "there is no target $of file" ; return 1; }
[ -s "$otf" ] || { echo "empty generated file $otf" ; return 1; }
rewrite_if_changed "$otf" "$of"
}
if [ -n "$1" ] ; then
gen_static_fallback "${1/-manual/}"
exit
fi
grep "include/static-fallback-.*\.conf" /etc/nginx/sites-enabled.d/azbyka.d/*.conf | sed -e "s|:.*||g" | xargs -n1 -I"{}" basename "{}" .conf | sort -u | while read f ; do
gen_static_fallback "${f/-manual/}"
#exit
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment