move driver code for chapter 4 inside chapter 4 folder

This commit is contained in:
Aditya 2023-01-22 21:20:56 +05:30
parent 811dc4fe1d
commit dc3d878e75
2 changed files with 57 additions and 31 deletions

55
scripts/chapter4/main.sh Normal file
View file

@ -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
}
echo "Creating directories"
su -c "bash ./4.2-create-dir.sh"
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.2-create-dir.sh"
fi
# Chapter 4.3
# ===========
echo "Adding LFS user"
su -c "bash ./4.3-add-user.sh"
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.3-add-user.sh"
fi
PWD=$(pwd)
# Chapter 4.4
# ===========
echo "Setting Up the Environment"
su - lfs -c "bash $PWD/4.4-set-up-env.sh"
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.4-set-up-env.sh"
fi

View file

@ -62,42 +62,13 @@ fi
# Chapter 4
# =========
echo "Chapter 4"
echo "Creating direcctories"
su -c "bash ./chapter4/4.2-create-dir.sh"
bash ./chapter4/main.sh
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.2-create-dir.sh"
fi
# Chapter 4.3
# ===========
echo "Adding LFS user"
su -c "bash ./chapter4/4.3-add-user.sh"
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.3-add-user.sh"
fi
<<<<<<< HEAD
PWD=$(pwd)
# Chapter 4.4
# ===========
echo "Setting Up the Environment"
su - lfs -c "bash $PWD/chapter4/4.4-set-up-env.sh"
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter4/4.4-set-up-env.sh"
stop_script "Stopped in chapter 4"
fi
# Chapter 5.2