Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-10-2008, 02:01 PM
Antoine Jacoutot
 
Posts: n/a
Default sysmerge non-interactive mode

Hi.

This diff adds a non-interactive mode to sysmerge.
It may be handy when updating several boxen (or one even) as it will
save differing files so you can diff/merge them later yourself after
further inspection.
Also yesno was only used once so nuke it.

Man page bits enhancements from jmc@.
Comments?

===> http://www.bsdfrog.org/tmp/sysmerge.diff


Index: sysmerge.8
================================================== =================
RCS file: /cvs/src/usr.sbin/sysmerge/sysmerge.8,v
retrieving revision 1.3
diff -u -r1.3 sysmerge.8
--- sysmerge.8 30 Apr 2008 20:15:54 -0000 1.3
+++ sysmerge.8 8 May 2008 14:30:43 -0000
@@ -22,7 +22,7 @@
.Nd update system configuration files
.Sh SYNOPSIS
.Nm
-.Op Fl a
+.Op Fl ab
.Op Fl s Ar src \*(Ba etcXX.tgz
.Op Fl x Ar xetcXX.tgz
.Sh DESCRIPTION
@@ -122,6 +122,12 @@
will automatically install missing files,
create databases and device nodes,
and will disable strict file comparison when possible (using CVS Ids).
+.It Fl b
+Batch mode.
+If this option is specified,
+.Nm
+will run unattended (non-interactively), saving differing files for
+later manual processing.
.It Fl s Ar src \*(Ba etcXX.tgz
Specify a path to an
.Ox
Index: sysmerge.sh
================================================== =================
RCS file: /cvs/src/usr.sbin/sysmerge/sysmerge.sh,v
retrieving revision 1.5
diff -u -r1.5 sysmerge.sh
--- sysmerge.sh 30 Apr 2008 20:15:55 -0000 1.5
+++ sysmerge.sh 8 May 2008 14:30:43 -0000
@@ -30,20 +30,6 @@
PAGER="${PAGER:=/usr/bin/more}"
SWIDTH=`stty size | awk '{w=$2} END {if (w==0) {w=80} print w}'`

-yesno() {
- echo -n "${*}? (y|[n]) "
- read ANSWER
- case "${ANSWER}" in
- y|Y)
- echo ""
- return 0
- ;;
- *)
- return 1
- ;;
- esac
-}
-

do_pre() {
if [ `id -u` -ne 0 ]; then
@@ -73,11 +59,19 @@
echo " temp root directory: ${TEMPROOT}"
echo " backup directory: ${BKPDIR}"
echo ""
- if yesno "Continue"; then
- echo -n ""
- else
- rmdir ${WRKDIR} 2> /dev/null
- exit 1
+
+ if [ -z "${BATCHMODE}" ]; then
+ echo -n "Continue? (y|[n]) "
+ read ANSWER
+ case "${ANSWER}" in
+ y|Y)
+ echo ""
+ ;;
+ *)
+ rmdir ${WRKDIR} 2> /dev/null
+ exit 1
+ ;;
+ esac
fi
}

@@ -205,7 +199,11 @@


diff_loop() {
- HANDLE_COMPFILE=v
+ if [ "${BATCHMODE}" ]; then
+ HANDLE_COMPFILE=todo
+ else
+ HANDLE_COMPFILE=v
+ fi

while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "todo" ]; do
if [ "${HANDLE_COMPFILE}" = "v" ]; then
@@ -236,17 +234,21 @@
fi
fi

- echo " Use 'd' to delete the temporary ${COMPFILE}"
- echo " Use 'i' to install the temporary ${COMPFILE}"
- if [ -z "${NO_INSTALLED}" -a -z "${IS_BINFILE}" ]; then
- echo " Use 'm' to merge the temporary and installed versions"
- echo " Use 'v' to view the diff results again"
- fi
- echo ""
- echo " Default is to leave the temporary file to deal with by hand"
- echo ""
- echo -n "How should I deal with this? [Leave it for later] "
- read HANDLE_COMPFILE
+ if [ -z "${BATCHMODE}" ]; then
+ echo " Use 'd' to delete the temporary ${COMPFILE}"
+ echo " Use 'i' to install the temporary ${COMPFILE}"
+ if [ -z "${NO_INSTALLED}" -a -z "${IS_BINFILE}" ]; then
+ echo " Use 'm' to merge the temporary and installed versions"
+ echo " Use 'v' to view the diff results again"
+ fi
+ echo ""
+ echo " Default is to leave the temporary file to deal with by hand"
+ echo ""
+ echo -n "How should I deal with this? [Leave it for later] "
+ read HANDLE_COMPFILE
+ else
+ unset HANDLE_COMPFILE
+ fi

case "${HANDLE_COMPFILE}" in
[dD])
@@ -410,9 +412,9 @@
}


-ARGS=`getopt as:x: $*`
+ARGS=`getopt abs:x: $*`
if [ $? -ne 0 ]; then
- echo "usage: ${0##*/} [-a] [-s src | etcXX.tgz] [-x xetcXX.tgz]" >&2
+ echo "usage: ${0##*/} [-ab] [-s src | etcXX.tgz] [-x xetcXX.tgz]" >&2
exit 1
fi
set -- ${ARGS}
@@ -421,6 +423,9 @@
case "$1" in
-a)
AUTOMODE=yes
+ shift;;
+ -b)
+ BATCHMODE=1
shift;;
-s)
WHERE="${2}"



--
Antoine

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:47 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145