From 8b6e883ea30fb135f047dde1457cb7c8b797c241 Mon Sep 17 00:00:00 2001 From: Luca Di Maio Date: Fri, 2 Sep 2022 10:02:51 +0200 Subject: [PATCH] init: do host file sync only if they exist Signed-off-by: Luca Di Maio --- distrobox-init | 28 +++++++++++++++------------- distrobox-upgrade | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/distrobox-init b/distrobox-init index 2c99b0bf..e196875e 100755 --- a/distrobox-init +++ b/distrobox-init @@ -924,20 +924,22 @@ if [ "${init}" -eq 0 ]; then # do stuff, only if we need to. file_watch_src="/run/host${file_watch}" # check if the target file is a symlink and take the source - if [ -L "${file_watch_src}" ]; then - file_watch_src="$(readlink -f "/run/host${file_watch}")" - # if it's an absolute link, we need to append /run/host ourselves. - if ! echo "${file_watch_src}" | grep -q "/run/host"; then - file_watch_src="/run/host${file_watch_src}" + if [ -e "${file_watch_src}" ]; then + if [ -L "${file_watch_src}" ]; then + file_watch_src="$(readlink -f "/run/host${file_watch}")" + # if it's an absolute link, we need to append /run/host ourselves. + if ! echo "${file_watch_src}" | grep -q "/run/host"; then + file_watch_src="/run/host${file_watch_src}" + fi + fi + if ! diff "${file_watch}" "${file_watch_src}" > /dev/null; then + # We only do this, if the file is a bind mount in the first place. + # This could be useful for init-hooks that involve umounting those + # files so that can be separated from the host. + mountpoint "${file_watch}" && + umount "${file_watch}" && + mount_bind "/run/host${file_watch}" "${file_watch}" rw fi - fi - if ! diff "${file_watch}" "${file_watch_src}" > /dev/null; then - # We only do this, if the file is a bind mount in the first place. - # This could be useful for init-hooks that involve umounting those - # files so that can be separated from the host. - mountpoint "${file_watch}" && - umount "${file_watch}" && - mount_bind "/run/host${file_watch}" "${file_watch}" rw fi done sleep 15 diff --git a/distrobox-upgrade b/distrobox-upgrade index 992c42c8..879b38d0 100755 --- a/distrobox-upgrade +++ b/distrobox-upgrade @@ -31,6 +31,7 @@ all=0 container_manager="autodetect" distrobox_path="$(dirname "$(realpath "${0}")")" distrobox_sudo_program="sudo" +rootful=0 verbose=0 version="1.3.2"