Improved safety and code quality

This commit is contained in:
2022-02-21 20:37:26 +08:00
parent 4302397f37
commit ef33db4288

View File

@ -3,29 +3,29 @@
# just gonna assume you're executing in the scripts folder # just gonna assume you're executing in the scripts folder
# build the blog files # build the blog files
cd ../blog cd ../blog || exit
CONTENTNUM=$(($(ls content-* | wc -l)-1)) CONTENTNUM=$(($( find . -type f -name "content-*" | wc -l)-1))
for ((i=-1;i<$CONTENTNUM;i++)) for ((i=-1;i<CONTENTNUM;i++))
do do
# separate files by respective static pages # separate files by respective static pages
padint="$(printf %03d $i)" padint="$(printf %03d "$i")"
contentname="content-$padint" contentname="content-$padint"
quotename="quote-$padint" quotename="quote-$padint"
tailname="tail-$padint" tailname="tail-$padint"
blogname="blog-$padint" blogname="blog-$padint"
# interactive tail # interactive tail
if (( $i >= 0 )) ;then if (( i >= 0 )) ;then
# prepare tail template # prepare tail template
cp filetail "$tailname" cp filetail "$tailname"
# increment int if the page exists # increment int if the page exists
padintprev="$(printf %03d $(($i - 1)) )" padintprev="$(printf %03d $((i - 1)) )"
if (( $(($i+1)) == $CONTENTNUM )) ;then if (( $((i+1)) == CONTENTNUM )) ;then
padintnext="$(printf %03d -1 )" padintnext="$(printf %03d -1 )"
else else
padintnext="$(printf %03d $(($i + 1)) )" padintnext="$(printf %03d $((i + 1)) )"
fi fi
# replace placeholders # replace placeholders
@ -40,9 +40,9 @@ do
done done
# clean up non prod files, lock down permissions, and self-destruct # clean up non prod files, lock down permissions, and self-destruct
cd ../blog cd ../blog || exit
\rm filehead filetail content* quote* .blog.* tail* \rm filehead filetail content* quote* .blog.* tail*
cd ../ cd ../ || exit
\rm -rf .git scripts .index.html.* README.md Jenkinsfile \rm -rf .git scripts .index.html.* README.md Jenkinsfile
find . -type f | xargs chmod 600 find . -type f -exec chmod 600 {} \;
find . -type d | xargs chmod 700 find . -type d -exec chmod 700 {} \;