fix exit on 404 code and space in vars

This commit is contained in:
Ahmed AbouZaid 2019-02-01 09:27:32 +01:00
parent f05b66ee19
commit b2db3af075
2 changed files with 17 additions and 18 deletions

View File

@ -1,25 +1,23 @@
# Google SRE Books.
# NOTE: The indentation before inner vars should be always "tab" not "space".
declare -A BOOKS
BOOKS=(
# Site Reliability Engineering
["SRE_BOOK"]=$(
echo '
BOOK_NAME=sre-book
BOOK_NAME_FULL=Site Reliability Engineering
BOOK_FILE=google-sre-book
BOOK_TOC_URL=https://landing.google.com/sre/sre-book/toc/index.html
'
)
["SRE_BOOK"]='
BOOK_NAME=sre-book
BOOK_NAME_FULL=Site Reliability Engineering
BOOK_FILE=google-sre-book
BOOK_TOC_URL=https://landing.google.com/sre/sre-book/toc/index.html
'
# Site Reliability Workbook
["SRW_BOOK"]=$(
echo '
BOOK_NAME=workbook
BOOK_NAME_FULL=The Site Reliability Workbook
BOOK_FILE=google-sre-workbook
BOOK_TOC_URL=https://landing.google.com/sre/workbook/toc/index.html
'
)
["SRW_BOOK"]='
BOOK_NAME=workbook
BOOK_NAME_FULL=The Site Reliability Workbook
BOOK_FILE=google-sre-workbook
BOOK_TOC_URL=https://landing.google.com/sre/workbook/toc/index.html
'
)

View File

@ -3,13 +3,13 @@ if [[ "${DEBUG}" == 1 ]]; then
set -x
fi
set -euo pipefail
IFS=$'\n\t'
# Get book details.
source books.sh
export ${BOOKS[${BOOK_SLUG^^}]}
# Common vars.
IFS=$'\n\t'
IMGS_DOMAIN="lh3.googleusercontent.com"
#
@ -20,6 +20,7 @@ IMGS_DOMAIN="lh3.googleusercontent.com"
# Enable recursion, timestamping (--mirror)
# Images are hosted elsewhere, download them as well.
# We need to go up a level from /toc/ where we start
# The "ture" at the end to ignore non-200 URLs like 404.
wget \
--convert-links \
--directory-prefix=html \
@ -31,7 +32,7 @@ wget \
--mirror \
--no-verbose \
--recursive \
--domains=${IMGS_DOMAIN},landing.google.com ${BOOK_TOC_URL}
--domains=${IMGS_DOMAIN},landing.google.com ${BOOK_TOC_URL} || true
#
echo "Get working mode..."