Stop relying on SU

This commit is contained in:
Aditya 2023-01-06 11:16:03 +05:30
parent adf65dfb8c
commit 0b97320e00

View file

@ -1,6 +1,7 @@
#!/bin/bash
# Set SU
# ======
if [ $? -eq 1 ]
then
SU=doas
@ -8,6 +9,8 @@ else
SU=sudo
fi
# Exit on error
# =============
exit_status=0
function check_exit_code() {
@ -24,35 +27,89 @@ function stop_script() {
exit 1
}
# Chapter 2
# =========
echo "Chapter 2"
echo "Checking required packages"
bash ./chapter2/2.2-version-check.sh
echo "Creating filesystem"
$SU bash ./chapter2/2.5-create-filesystem.sh
echo "Mounting filesystem"
$SU bash ./chapter2/2.7-mount.sh
echo "Chapter 3"
echo "Downloading sources"
bash ./chapter3/3.1-sources.sh
echo "Chapter 4"
echo "Creating direcctories"
$SU bash ./chapter4/4.2-create-dir.sh
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter2/2.2-version-check.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
# =========
echo "Chapter 3"
echo "Downloading sources"
bash ./chapter3/3.1-sources.sh
# Exit on error
check_exit_code
if [ $exit_status -ne 0 ]
then
stop_script "chapter3/3.1-sources.sh"
fi
# Chapter 4
# =========
echo "Chapter 4"
echo "Creating direcctories"
su -c "bash ./chapter4/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 ./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