From e42268b483e9d267b0a639de1aefbba83f4154b7 Mon Sep 17 00:00:00 2001 From: Aditya Date: Sun, 22 Jan 2023 22:25:36 +0530 Subject: [PATCH] move driver code for chapter 10 inside chapter 10 folder --- scripts/chapter10/main.sh | 55 +++++++++++++++++++++++++++++++++++++++ scripts/main.sh | 33 +++-------------------- 2 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 scripts/chapter10/main.sh diff --git a/scripts/chapter10/main.sh b/scripts/chapter10/main.sh new file mode 100644 index 0000000..469cbc1 --- /dev/null +++ b/scripts/chapter10/main.sh @@ -0,0 +1,55 @@ +#!/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 +} + +# Chapter 10.2 +# ============ +echo "Creating /etc/fstab" +su -c "bash $SCRIPT/chapter10/10.2-fstab.sh" + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter10/10.2-fstab.sh" +fi + +# Chapter 10.3 +# ============ +echo "Building kernel" +su -c "bash $SCRIPT/chapter10/10.3-kernel.sh" + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter10/10.3-kernel.sh" +fi + +# Chapter 10.4 +# ============ +echo "Installng grub" +su -c "bash $SCRIPT/chapter10/10.4-grub.sh" + +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter10/10.4-grub.sh" +fi diff --git a/scripts/main.sh b/scripts/main.sh index 0991355..77d0aab 100644 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -201,41 +201,16 @@ then stop_script "Stopped in chapter 9" fi -# Chapter 10.2 -# ============ +# Chapter 10 +# ========== echo "Chapter 10" -echo "Creating /etc/fstab" -su -c "bash $SCRIPT/chapter10/10.2-fstab.sh" +bash ./chapter10/main.sh # Exit on error check_exit_code if [ $exit_status -ne 0 ] then - stop_script "chapter10/10.2-fstab.sh" -fi - -# Chapter 10.3 -# ============ -echo "Building kernel" -su -c "bash $SCRIPT/chapter10/10.3-kernel.sh" - -# Exit on error -check_exit_code -if [ $exit_status -ne 0 ] -then - stop_script "chapter10/10.3-kernel.sh" -fi - -# Chapter 10.4 -# ============ -echo "Installng grub" -su -c "bash $SCRIPT/chapter10/10.4-grub.sh" - -# Exit on error -check_exit_code -if [ $exit_status -ne 0 ] -then - stop_script "chapter10/10.4-grub.sh" + stop_script "Stopped in chapter 10" fi # Chapter 11.1