move driver code for chapter 2 inside chapter 2 folder

This commit is contained in:
Aditya 2023-01-22 19:56:54 +05:30
parent 6e56b9c05c
commit 8fa5a3a782
2 changed files with 56 additions and 28 deletions

54
scripts/chapter2/main.sh Normal file
View file

@ -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

View file

@ -32,46 +32,20 @@ function stop_script() {
# Chapter 2 # Chapter 2
# ========= # =========
echo "Chapter 2" echo "Chapter 2"
echo "Checking required packages" bash ./chapter2/main.sh
bash ./chapter2/2.2-version-check.sh
# Exit on error # Exit on error
check_exit_code check_exit_code
if [ $exit_status -ne 0 ] if [ $exit_status -ne 0 ]
then then
stop_script "chapter2/2.2-version-check.sh" stop_script "chapter3/3.1-sources.sh"
fi fi
# Set LFS variable # Set LFS variable
# ================ # ================
export LFS=/mnt/lfs export LFS=/mnt/lfs
echo "LFS is $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 # Chapter 3