From 0dd6052e8e4672245bb3cb1fa8b5cec0de4ce97d Mon Sep 17 00:00:00 2001 From: Anthony Basile Date: Sun, 12 Dec 2010 18:30:45 -0500 Subject: [PATCH] etc-update: add option to save example config This will fix bug #348561. --- bin/etc-update | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/bin/etc-update b/bin/etc-update index e282a307c..d4ed6e689 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -339,6 +339,7 @@ do_cfg() { 2) Delete update, keeping original as is 3) Interactively merge original with update 4) Show differences again +5) Save update as example config Please select from the menu above (-1 to ignore this update): " my_input=$(read_int) fi @@ -361,6 +362,8 @@ Please select from the menu above (-1 to ignore this update): " ;; 4) continue ;; + 5) do_distconf "${file}" "${ofile}" + ;; *) continue ;; esac @@ -444,6 +447,36 @@ Please select from the menu above (-1 to exit, losing this merge): " return 255 } +do_distconf() { + # search for any previously saved distribution config + # files and number the current one accordingly + + local file="${1}" + local ofile="${2}" + local -i count + local -i size + local -i fill + local -i f + local suffix + local efile + + for count in $(seq 0 9999); do + size=${#count} + let fill=$((4-$size)) + suffix=".dist_" + for f in $(seq 1 $fill); do + suffix+="0" + done + suffix+="${count}" + efile="${ofile}${suffix}" + if [[ ! -f ${efile} ]]; then + echo ${efile} + mv ${mv_opts} ${file} ${efile} + break + fi + done +} + die() { trap SIGTERM trap SIGINT -- 2.26.2