From 9ebe6122e5f7dd378bba60dc7249acecc0847cd7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 18 Jan 2014 05:14:08 -0500 Subject: [PATCH] custom-chroot: skip files that do not exist --- .bin/custom-chroot | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.bin/custom-chroot b/.bin/custom-chroot index 113ccfa..1306cb9 100755 --- a/.bin/custom-chroot +++ b/.bin/custom-chroot @@ -38,10 +38,9 @@ init_chroot() { [[ -w . ]] || return 0 if [[ ! -L etc/mtab ]] ; then - rm -f etc/mtab - ln -sf /proc/mounts etc/mtab + ln -sfT /proc/mounts etc/mtab fi - local f + local f dst local etc=( hosts locale.gen @@ -57,14 +56,22 @@ init_chroot() { for f in \ $(printf 'etc/%s ' "${etc[@]}") \ ; do - if [ -e "/${f}" ] ; then - cp /${f} ${f} + if [[ -e /${f} ]] ; then + cp "/${f}" "${f}" fi done for f in "${home[@]}" ; do - cp "${HOME}/${f}" "root/${f}" + df="root/${f}" + f="${HOME}/${f}" + if [[ -e ${f} ]] ; then + cp "${f}" "${df}" + fi done - cat ~/.profile.d/aliases.sh > root/.bash_profile + + f="${HOME}/.profile.d/aliases.sh" + if [[ -e ${f} ]] ; then + cat "${f}" > root/.bash_profile + fi } usage() { -- 2.39.5