diff --git a/scripts/chapter3/main.sh b/scripts/chapter3/main.sh new file mode 100644 index 0000000..ed77a56 --- /dev/null +++ b/scripts/chapter3/main.sh @@ -0,0 +1,31 @@ +#!/bin/bash + + +# Exit on error +# ============= +exit_status=0 + +function check_exit_code() { + if [ $? -ne 0 ] + then + exit_status=1 + else + exit_status=0 + fi +} + +function stop_script() { + echo "Script failed in $(pwd)/$1" + exit 1 +} + +echo "Downloading sources" +bash ./3.1-sources.sh + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter3/3.1-sources.sh" +fi + diff --git a/scripts/main.sh b/scripts/main.sh index 2ee0541..adae690 100644 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -47,21 +47,18 @@ export LFS=/mnt/lfs echo "LFS is $LFS" - # Chapter 3 # ========= echo "Chapter 3" -echo "Downloading sources" -bash ./chapter3/3.1-sources.sh +bash ./chapter3/main.sh # Exit on error check_exit_code if [ $exit_status -ne 0 ] then - stop_script "chapter3/3.1-sources.sh" + stop_script "Stopped in chapter 3" fi - # Chapter 4 # ========= echo "Chapter 4"