add option to discard config updates
authorMarius Mauch <genone@gentoo.org>
Wed, 19 Jul 2006 10:21:32 +0000 (10:21 -0000)
committerMarius Mauch <genone@gentoo.org>
Wed, 19 Jul 2006 10:21:32 +0000 (10:21 -0000)
svn path=/main/trunk/; revision=3930

bin/etc-update

index 06ac3ddefa92ed81e94d9a35e995b2ef0ac3729e..a1f81342e56998ea37e4c694f869d9b5e7620e8d 100755 (executable)
@@ -122,6 +122,8 @@ function sel_file() {
 
                if [ "${OVERWRITE_ALL}" == "yes" ]; then
                        input=0
+               elif [ "${DELETE_ALL}" == "yes" ]; then
+                       input=0
                else
                        if [[ ${mode} == 0 ]] ; then
                                echo "The following is the list of files which need updating, each 
@@ -133,9 +135,11 @@ configuration file is followed by a list of possible replacement files."
                        if [[ ${mode} == 0 ]] ; then
                                cat ${TMP}/menuitems
                                echo    "Please select a file to edit by entering the corresponding number."
-                               echo    "              (don't use -3 or -5 if you're unsure what to do)"
+                               echo    "              (don't use -3, -5, -7 or -9 if you're unsure what to do)"
                                echo    "              (-1 to exit) (-3 to auto merge all remaining files)"
-                               echo -n "                           (-5 to auto-merge AND not use 'mv -i'): "
+                               echo    "                           (-5 to auto-merge AND not use 'mv -i')"
+                               echo    "                           (-7 to discard all updates)"
+                               echo -n "                           (-9 to discard all updates AND not use 'rm -i'):"
                                read input
                        else
                                dialog --title "${title}" --menu "${my_title}" \
@@ -143,6 +147,19 @@ configuration file is followed by a list of possible replacement files."
                                        2> ${TMP}/input || die "User termination!" 0
                                input=$(<${TMP}/input)
                        fi
+                       if [[ ${input} == -9 ]]; then
+                               read -p "Are you sure that you want to delete all updates (type YES):" reply
+                               if [[ ${reply} != "YES" ]]; then
+                                       continue
+                               else
+                                       input=-7
+                                       export rm_opts=""
+                               fi                              
+                       fi
+                       if [[ ${input} == -7 ]]; then
+                               input=0
+                               export DELETE_ALL="yes"
+                       fi
                        if [[ ${input} == -5 ]] ; then
                                input=-3
                                export mv_opts=""
@@ -172,6 +189,8 @@ function do_file() {
 
                        if [ "${OVERWRITE_ALL}" == "yes" ]; then
                                my_input=0
+                       elif [ "${DELETE_ALL}" == "yes" ]; then
+                               my_input=0
                        else
                                for line in $(<${TMP}/files/${input}); do
                                        if (( ${fcount} > 0 )); then
@@ -240,6 +259,8 @@ function do_cfg() {
        until (( ${my_input} == -1 )) || [ ! -f ${file} ]; do
                if [ "${OVERWRITE_ALL}" == "yes" ]; then
                        my_input=1
+               elif [ "${DELETE_ALL}" == "yes" ]; then
+                       my_input=2
                else
                  showdiffcmd=$(echo "${diff_command}" |
                                sed -e "s:%file1:${ofile}:" -e "s:%file2:${file}:")
@@ -273,11 +294,12 @@ Please select from the menu above (-1 to ignore this update): "
                case ${my_input} in
                        1) echo "Replacing ${ofile} with ${file}"
                           mv ${mv_opts} ${file} ${ofile}
-                          my_input=-1
+                          [ -n "${OVERWRITE_ALL}" ] && my_input=-1
                           continue
                           ;;
                        2) echo "Deleting ${file}"
                           rm ${rm_opts} ${file}
+                          [ -n "${DELETE_ALL}" ] && my_input=-1
                           continue
                           ;;
                        3) do_merge "${file}" "${ofile}"