diff options
author | Aaron LI <aly@aaronly.me> | 2018-03-10 21:35:29 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-03-10 21:35:29 +0800 |
commit | 1145b0b1659e84fba119a529e9d42656ce70b884 (patch) | |
tree | 379e5d10b2af3459816bc2a998c58c9bdcbbd89c | |
parent | e5bb27968e9a6ac92bfbbb051c96785c5a91ea34 (diff) | |
download | dfly-update-1145b0b1659e84fba119a529e9d42656ce70b884.tar.bz2 |
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"!
-rwxr-xr-x | dfly-update | 18 |
1 files 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" } |