From 1145b0b1659e84fba119a529e9d42656ce70b884 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 10 Mar 2018 21:35:29 +0800 Subject: install_system(): check file existence before stash/recover; use cp The important etc confg files (e.g., group, passwd) cannot be moved/renamed! Use "cp" instead of "mv"! --- dfly-update | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dfly-update b/dfly-update index 650f3f1..6465d45 100755 --- a/dfly-update +++ b/dfly-update @@ -404,10 +404,12 @@ install_system() { echo "Installing the new kernel and world ..." echo " => Stashing the files to protect from overriding ..." for file in ${FILES_IGNORE}; do - file2="${file}.${BAK_SUF}" - echo -n " * ${file} " - mv -f "${file}" "${file2}" - echo "(stashed)" + if [ -f "${file}" ]; then + file2="${file}.${BAK_SUF}" + echo -n " * ${file} " + cp -af "${file}" "${file2}" # NOTE: do NOT use "mv" + echo "(stashed)" + fi done echo " => Creating distribution directories ..." @@ -449,9 +451,11 @@ install_system() { echo " => Recovering the stashed files ..." for file in ${FILES_IGNORE}; do file2="${file}.${BAK_SUF}" - echo -n " * ${file} " - mv -f "${file2}" "${file}" - echo "(recovered)" + if [ -f "${file2}" ]; then + echo -n " * ${file} " + mv -f "${file2}" "${file}" + echo "(recovered)" + fi done echo " => DONE" } -- cgit v1.2.2