sysmerge non-interactive mode
  Home FAQ Contact Sign in
mailing.openbsd.tech only
 
Advanced search
POPULAR GROUPS

more...

 Up
sysmerge non-interactive mode         

Group: mailing.openbsd.tech · Group Profile
Author: Antoine Jacoutot
Date: May 8, 2008 12:49

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
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Re: iTunes non è una monnezza perchè non si può dire ma ad essere onesti...it.comp.macintosh ·