From 415fa0f809c423bab891c3baa97c2be20b602577 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 24 Mar 2021 09:46:25 -0500 Subject: Adjust indention. --- chapter6/backup.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index 6ffe768..0f77869 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -9,16 +9,16 @@ else echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${FILE}${RST}... " pushd "${LFS}" > /dev/null || exit 1 - sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${FILE}" "${DIRS[@]}" & pid=$! - spinner "$pid" - retval=$? - if [ "$retval" -ne 0 ]; then - echo -e "${RED}Backup FAILED!${RST}" - exit 1 - else - sudo chown "${USER}" /home/"${USER}"/"${FILE}" - echo -e "${GRN}OK${RST}" - fi + sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${FILE}" "${DIRS[@]}" & pid=$! + spinner "$pid" + retval=$? + if [ "$retval" -ne 0 ]; then + echo -e "${RED}Backup FAILED!${RST}" + exit 1 + else + sudo chown "${USER}" /home/"${USER}"/"${FILE}" + echo -e "${GRN}OK${RST}" + fi popd > /dev/null || exit 1 touch "${LFS}/sources/chapter6/backup" -- cgit v1.2.3-54-g00ecf From 6b7897b097285d8c1f76ccdf2c49464eb9875a16 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 24 Mar 2021 11:04:53 -0500 Subject: Adjust some text and use printf. --- chapter6/backup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index 0f77869..842ed27 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -4,7 +4,7 @@ FILE="${LFS_VER}-ch6-backup.tar.xz" DIRS=(bin etc lib lib64 sbin tools usr var) if [ -f "${LFS}/sources/chapter6/backup" ]; then - echo -e "${GRN}Backup found. Remove manually to backup again.${RST}" + printf "%b" "${YLW}Chapter 6 ${GRN}Backup found. Remove manually to backup again.${RST}" else echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${FILE}${RST}... " @@ -13,11 +13,11 @@ else spinner "$pid" retval=$? if [ "$retval" -ne 0 ]; then - echo -e "${RED}Backup FAILED!${RST}" + printf "%b" "${RED}Backup FAILED!${RST}\n" exit 1 else sudo chown "${USER}" /home/"${USER}"/"${FILE}" - echo -e "${GRN}OK${RST}" + printf "%b" "${GRN}OK${RST}\n" fi popd > /dev/null || exit 1 -- cgit v1.2.3-54-g00ecf From e91f1d7aa947cbbe1c1605ed020d960220ba59b8 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Wed, 24 Mar 2021 11:20:20 -0500 Subject: Use HOME variable when changing ownership of backup archive. --- chapter6/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index 842ed27..c763d8c 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -16,7 +16,7 @@ else printf "%b" "${RED}Backup FAILED!${RST}\n" exit 1 else - sudo chown "${USER}" /home/"${USER}"/"${FILE}" + sudo chown "${USER}" "${HOME}"/"${FILE}" printf "%b" "${GRN}OK${RST}\n" fi popd > /dev/null || exit 1 -- cgit v1.2.3-54-g00ecf From 9ecb12be2d5093c1cf95f2bb25358d75ac8ea37b Mon Sep 17 00:00:00 2001 From: William Harrington Date: Thu, 25 Mar 2021 11:10:36 -0500 Subject: Change case of FILE to file and rename DIRS to directories. --- chapter6/backup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index c763d8c..99ddbe4 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -1,22 +1,22 @@ #!/bin/bash -FILE="${LFS_VER}-ch6-backup.tar.xz" -DIRS=(bin etc lib lib64 sbin tools usr var) +file="${LFS_VER}-ch6-backup.tar.xz" +directories=(bin etc lib lib64 sbin tools usr var) if [ -f "${LFS}/sources/chapter6/backup" ]; then printf "%b" "${YLW}Chapter 6 ${GRN}Backup found. Remove manually to backup again.${RST}" else - echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${FILE}${RST}... " + echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${file}${RST}... " pushd "${LFS}" > /dev/null || exit 1 - sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${FILE}" "${DIRS[@]}" & pid=$! + sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${file}" "${directories[@]}" & pid=$! spinner "$pid" retval=$? if [ "$retval" -ne 0 ]; then printf "%b" "${RED}Backup FAILED!${RST}\n" exit 1 else - sudo chown "${USER}" "${HOME}"/"${FILE}" + sudo chown "${USER}" "${HOME}"/"${file}" printf "%b" "${GRN}OK${RST}\n" fi popd > /dev/null || exit 1 -- cgit v1.2.3-54-g00ecf From a3e171ba292cadb20809adb944dbfae41924dbeb Mon Sep 17 00:00:00 2001 From: William Harrington Date: Thu, 25 Mar 2021 11:11:09 -0500 Subject: Unset variables no longer used. --- chapter6/backup.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index 99ddbe4..f2f0d64 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -23,3 +23,5 @@ else touch "${LFS}/sources/chapter6/backup" fi + +unset file directories -- cgit v1.2.3-54-g00ecf