From 8fa5a3a7824b7701de777f4aac427cb7afd91167 Mon Sep 17 00:00:00 2001 From: Aditya Date: Sun, 22 Jan 2023 19:56:54 +0530 Subject: [PATCH] move driver code for chapter 2 inside chapter 2 folder --- scripts/chapter2/main.sh | 54 ++++++++++++++++++++++++++++++++++++++++ scripts/main.sh | 30 ++-------------------- 2 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 scripts/chapter2/main.sh diff --git a/scripts/chapter2/main.sh b/scripts/chapter2/main.sh new file mode 100644 index 0000000..6e9c538 --- /dev/null +++ b/scripts/chapter2/main.sh @@ -0,0 +1,54 @@ +#!/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 "Checking required packages" +bash ./2.2-version-check.sh + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter2/2.2-version-check.sh" +fi + +# Chapter 2.5 +# =========== +echo "Creating filesystem" +su -c "bash ./2.5-create-filesystem.sh" + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter2/2.5-create-filesystem.sh" +fi + + +# Chapter 2.7 +# =========== +echo "Mounting filesystem" +su -c "bash ./2.7-mount.sh" + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter2/2.7-mount.sh" +fi diff --git a/scripts/main.sh b/scripts/main.sh index cbb604a..0e76576 100644 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -32,46 +32,20 @@ function stop_script() { # Chapter 2 # ========= echo "Chapter 2" -echo "Checking required packages" -bash ./chapter2/2.2-version-check.sh +bash ./chapter2/main.sh # Exit on error check_exit_code if [ $exit_status -ne 0 ] then - stop_script "chapter2/2.2-version-check.sh" + stop_script "chapter3/3.1-sources.sh" fi - # Set LFS variable # ================ export LFS=/mnt/lfs echo "LFS is $LFS" -# Chapter 2.5 -# =========== -echo "Creating filesystem" -su -c "bash ./chapter2/2.5-create-filesystem.sh" - -# Exit on error -check_exit_code -if [ $exit_status -ne 0 ] -then - stop_script "chapter2/2.5-create-filesystem.sh" -fi - - -# Chapter 2.7 -# =========== -echo "Mounting filesystem" -su -c "bash ./chapter2/2.7-mount.sh" - -# Exit on error -check_exit_code -if [ $exit_status -ne 0 ] -then - stop_script "chapter2/2.7-mount.sh" -fi # Chapter 3