Skip to content

Commit 1167609

Browse files
authored
Use strict error handling in bash scripts (#3083)
1 parent 16a4d63 commit 1167609

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

build_submodules.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -xe
3+
set -xe -o pipefail -o nounset
44

55
project_root=$(pwd)
66

@@ -31,14 +31,14 @@ cartridge_pot_src="${cartridge_root}/build.luarocks/build.rst/locale"
3131
cartridge_pot_dest="${project_root}/locale/book/cartridge"
3232
cd "${cartridge_pot_src}" || exit
3333
mkdir -p "${cartridge_pot_dest}"
34-
find . -name '*.pot' -exec cp -r --parents {} "${cartridge_pot_dest}" \;
34+
find . -name '*.pot' -exec cp -rv --parents {} "${cartridge_pot_dest}" \;
3535

3636
# Copy translations
3737
cartridge_po_src="${cartridge_root}/build.luarocks/build.rst/locale/ru/LC_MESSAGES"
3838
cartridge_po_dest="${po_dest}/book/cartridge"
3939
cd "${cartridge_po_src}" || exit
4040
mkdir -p "${cartridge_po_dest}"
41-
find . -name '*.po' -exec cp -r --parents {} "${cartridge_po_dest}" \;
41+
find . -name '*.po' -exec cp -rv --parents {} "${cartridge_po_dest}" \;
4242

4343

4444
# Cartridge CLI
@@ -67,8 +67,8 @@ monitoring_grafana_root="${project_root}/modules/grafana-dashboard/doc/monitorin
6767

6868
# Copy monitoring docs to the right destination
6969
mkdir -p "${monitoring_dest}"
70-
yes | cp -rf "${monitoring_root}" "${monitoring_dest}/"
71-
yes | cp -rf "${monitoring_grafana_root}" "${monitoring_dest}/"
70+
cp -rfv "${monitoring_root}" "${monitoring_dest}/"
71+
cp -rfv "${monitoring_grafana_root}" "${monitoring_dest}/"
7272

7373

7474
# Luatest
@@ -81,10 +81,10 @@ ldoc --ext=rst --dir=rst --toctree="API" .
8181

8282
# Copy Luatest docs to the right place
8383
cd "${luatest_dest}"
84-
yes | cp -fa "${luatest_root}/rst/." "${luatest_dest}"
85-
yes | cp "${luatest_root}/README.rst" "${luatest_dest}"
84+
cp -fa "${luatest_root}/rst/." "${luatest_dest}"
85+
cp "${luatest_root}/README.rst" "${luatest_dest}"
8686
mkdir -p "${luatest_dest}/_includes/"
87-
yes | mv -f "${luatest_dest}/index.rst" "${luatest_dest}/_includes/"
87+
mv -fv "${luatest_dest}/index.rst" "${luatest_dest}/_includes/"
8888

8989

9090
# Kubernetes operator
@@ -93,7 +93,7 @@ cartridge_kubernetes_dest="${cartridge_rst_dest}/"
9393

9494
# Copy Kubernetes operator docs to the right place
9595
mkdir -p "${cartridge_kubernetes_dest}"
96-
yes | cp -rf "${cartridge_kubernetes_root}" "${cartridge_kubernetes_dest}"
96+
cp -rfv "${cartridge_kubernetes_root}" "${cartridge_kubernetes_dest}"
9797

9898

9999
# Tarantool C++ connector
@@ -104,6 +104,6 @@ tntcxx_api_dest="${project_root}/doc/book/connectors"
104104
# Copy Tarantool C++ connector docs to the right places
105105
mkdir -p "${tntcxx_api_dest}/cxx/"
106106
mkdir -p "${tntcxx_gs_dest}/_includes"
107-
yes | cp -rf "${tntcxx_root}/doc/tntcxx_getting_started.rst" "${tntcxx_gs_dest}/getting_started_cxx.rst"
108-
yes | cp -rf "${tntcxx_root}/examples/" "${tntcxx_gs_dest}/_includes/examples/"
109-
yes | cp -rf "${tntcxx_root}/doc/tntcxx_api.rst" "${tntcxx_api_dest}/cxx/"
107+
cp -rfv "${tntcxx_root}/doc/tntcxx_getting_started.rst" "${tntcxx_gs_dest}/getting_started_cxx.rst"
108+
cp -rfv "${tntcxx_root}/examples/" "${tntcxx_gs_dest}/_includes/examples/"
109+
cp -rfv "${tntcxx_root}/doc/tntcxx_api.rst" "${tntcxx_api_dest}/cxx/"

upload_output.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
set -xe -o pipefail -o nounset
4+
35
BRANCH=$BRANCH_NAME
46
ENDPOINT_URL=$S3_ENDPOINT_URL
57
S3_PATH=$S3_UPLOAD_PATH
@@ -13,18 +15,25 @@ aws s3 sync output/json/_build_en/json/_images $S3_PATH/$BRANCH/images_en --endp
1315
aws s3 sync output/json/_build_ru/json/_images $S3_PATH/$BRANCH/images_ru --endpoint-url=$ENDPOINT_URL --delete --size-only
1416

1517
# upload pdf files
16-
aws s3 cp --acl public-read output/_latex_en/Tarantool.pdf $S3_PATH/$BRANCH/Tarantool-en.pdf --endpoint-url=$ENDPOINT_URL
17-
aws s3 cp --acl public-read output/_latex_ru/Tarantool.pdf $S3_PATH/$BRANCH/Tarantool-ru.pdf --endpoint-url=$ENDPOINT_URL
18+
if [ -f output/_latex_en/Tarantool.pdf ]; then
19+
aws s3 cp --acl public-read output/_latex_en/Tarantool.pdf $S3_PATH/$BRANCH/Tarantool-en.pdf --endpoint-url=$ENDPOINT_URL
20+
fi
21+
if [ -f output/_latex_ru/Tarantool.pdf ]; then
22+
aws s3 cp --acl public-read output/_latex_ru/Tarantool.pdf $S3_PATH/$BRANCH/Tarantool-ru.pdf --endpoint-url=$ENDPOINT_URL
23+
fi
1824

1925
# upload singlehtml and assets
26+
if [ -f output/html/en/singlehtml.html ]; then
2027
aws s3 sync --acl public-read output/html/en/_static $S3_PATH/$BRANCH/en/_static --endpoint-url=$ENDPOINT_URL --delete --size-only
2128
aws s3 sync --acl public-read output/html/en/_images $S3_PATH/$BRANCH/en/_images --endpoint-url=$ENDPOINT_URL --delete --size-only
2229
aws s3 cp --acl public-read output/html/en/singlehtml.html $S3_PATH/$BRANCH/en/singlehtml.html --endpoint-url=$ENDPOINT_URL
30+
fi
31+
if [ -f output/html/ru/singlehtml.html ]; then
2332
aws s3 sync --acl public-read output/html/ru/_static $S3_PATH/$BRANCH/ru/_static --endpoint-url=$ENDPOINT_URL --delete --size-only
2433
aws s3 sync --acl public-read output/html/ru/_images $S3_PATH/$BRANCH/ru/_images --endpoint-url=$ENDPOINT_URL --delete --size-only
2534
aws s3 cp --acl public-read output/html/ru/singlehtml.html $S3_PATH/$BRANCH/ru/singlehtml.html --endpoint-url=$ENDPOINT_URL
35+
fi
2636

27-
set -xe
2837
curl --fail --show-error \
2938
--data '{"update_key":"'"$TARANTOOL_UPDATE_KEY"'"}' \
3039
--header "Content-Type: application/json" \

0 commit comments

Comments
 (0)