PACKAGE = nsict-utils
VERSION = 1.1.1
-BINSCRIPTS = cdb-assign cdb-list check-sender unfwd splitconf z
+BINSCRIPTS = \
+ cdb-assign cdb-list check-sender unfwd \
+ splitconf z buf create inplace
SBINSCRIPTS = shadowfix
SCRIPTS = $(BINSCRIPTS) $(SBINSCRIPTS)
BINPROGS = not cdb-probe cdb-check-domain gorp locking if-mtu pause
LIBS = xtitle.so
DISTMAN1 = \
not.1 z.1 cdb-assign.1 cdb-list.1 cdb-probe.1 cdb-check-domain.1 \
- gorp.1 unfwd.1 splitconf.1 locking.1 if-mtu.1 pause.1
+ gorp.1 unfwd.1 splitconf.1 locking.1 if-mtu.1 pause.1 \
+ buf.1 create.1 inplace.1
MAN1 = $(DISTMAN1)
DISTMAN8 = qmail-checkspam.8
MAN8 = $(DISTMAN8) shadowfix.8
--- /dev/null
+#! /bin/sh
+
+set -e
+case "$#:$1" in
+ 0:* | 1:-h | 1:--help)
+ echo "Usage: $0 PROG ARGS..."
+ echo " Buffer stdin to temp file and pass to PROG with ARGS"
+ exit 0
+ ;;
+esac
+tmp=${TMPDIR-/tmp}/buf-$$
+mkdir "$tmp"
+trap 'rm -rf "$tmp"' INT QUIT TERM HUP EXIT
+cat >"$tmp/buf"
+set +e; "$@" "$tmp/buf"; st=$?; set -e
+trap '' INT QUIT TERM HUP EXIT
+rm -rf "$tmp"
+exit $st
--- /dev/null
+.de VS
+.sp 1
+.RS
+.nf
+.ft B
+..
+.de VE
+.ft R
+.fi
+.RE
+.sp 1
+..
+.TH buf 1 "5 February 2005" "Edgeware tools"
+.SH NAME
+buf \- buffer stdin to a file
+.SH SYNOPSIS
+.B buf
+.I command
+.RI [ arguments ...]
+.SH DESCRIPTION
+The
+.B buf
+program writes standard input to a temporary file. It then runs
+.VS
+.IR "command arguments " ... " stdinfile"
+.VE
+and exits with whatever exit status that exited with.
+.PP
+This is particularly useful for programs which want to seek their
+standard input, for example PostScript viewers. A typical invokation
+might be something like
+.VS
+man -Tps buf | buf gv
+.VE
+.SH BUGS
+Doesn't exit correctly if subprogram was killed by a signal.
+.SH AUTHOR
+Mark Wooding (mdw@nsict.org).
--- /dev/null
+#! /bin/sh
+
+set -e
+case "$#:$1" in
+ 0:* | 1:-h | 1:--help)
+ echo "$0 FILE PROG ARGS"
+ echo " Run PROG with ARGS, writing its stdout to FILE if it succeeds."
+ echo " Clobbers FILE.new."
+ exit 0
+ ;;
+ 1:*)
+ echo >&2 "$0 FILE PROG ARGS"
+ exit 1
+ ;;
+esac
+file=$1; shift
+set +e; "$@" >"$file.new"; st=$?; set -e
+if [ $st -eq 0 ]; then
+ mv "$file.new" "$file"
+else
+ rm "$file.new"
+fi
+exit $st
--- /dev/null
+.de VS
+.sp 1
+.RS
+.nf
+.ft B
+..
+.de VE
+.ft R
+.fi
+.RE
+.sp 1
+..
+.TH create 1 "5 February 2005" "Edgeware tools"
+.SH NAME
+create \- write new file safely
+.SH SYNOPSIS
+.B create
+.I file
+.I program
+.RI [ arguments ...]
+.SH DESCRIPTION
+The
+.B create
+program
+runs
+.VS
+.IR "program arguments " ...
+.VE
+redirecting standard output to
+.IR file \c
+.BR .new .
+If
+.I program
+exits successfully,
+.B create
+will rename the newly-written
+.IB file .new
+to simply
+.I file
+and exit zero; otherwise it deletes
+.IB file .new
+and exits the same as
+.I program
+did.
+.SH BUGS
+Doesn't exit correctly if subprogram was killed by a signal.
+.SH AUTHOR
+Mark Wooding (mdw@nsict.org).
Architecture: all
Section: utils
Depends: mdwopt-perl, nsict-cdb, locking, qmail-checkspam, nsict-mail,
- if-mtu, shadowfix, zz, gorp, splitconf, xtitle
+ if-mtu, shadowfix, zz, gorp, splitconf, xtitle, buf, create, inplace
Description: Dummy package for convenience.
Package: mdwopt-perl
Section: utils
Description: Wait for a given time, or until a key is pressed.
+Package: buf
+Architecture: all
+Section: utils
+Description: Captures stdin in a temporary file and runs a command.
+
+Package: create
+Architecture: all
+Section: utils
+Description: Simple script encapsulating atomic file update.
+
+Package: inplace
+Architecture: all
+Section: utils
+Description: Update files in place safely.
MdwOpt.pm mdwopt-perl /usr/share/perl5
+buf buf /usr/bin
+buf.1 buf /usr/share/man/man1
cdb-assign nsict-cdb /usr/bin
cdb-assign.1 nsict-cdb /usr/share/man/man1
cdb-check-domain nsict-cdb /usr/bin
cdb-probe.1 nsict-cdb /usr/share/man/man1
check-sender nsict-mail /usr/bin
check-sender.1 nsict-mail /usr/share/man/man1
+create create /usr/bin
+create.1 create /usr/share/man/man1
gorp gorp /usr/bin
gorp.1 gorp /usr/share/man/man1
if-mtu if-mtu /usr/sbin
if-mtu.1 if-mtu /usr/share/man/man1
+inplace inplace /usr/bin
+inplace.1 inplace /usr/share/man/man1
locking locking /usr/bin
locking.1 locking /usr/share/man/man1
not nsict-mail /usr/bin
--- /dev/null
+#! /bin/bash
+
+set -e
+usage () { echo >&2 "$0 FILE ... -- PROG ARGS"; exit 1; }
+case "$#:$1" in
+ 0:* | 1:-h | 1:--help)
+ echo "$0 FILE ... -- PROG ARGS"
+ echo " For each FILE, run PROG ARGS with stdin from FILE. If all is"
+ echo " good, replace each FILE with the corresponding output."
+ echo " Clobbers FILE.old and FILE.new."
+ exit 0
+ ;;
+esac
+declare -a file
+while :; do
+ [ $# -eq 0 ] && usage
+ f=$1; shift
+ [ "$f" = -- ] && break
+ file=("${file[@]}" "$f")
+done
+[ $# -eq 0 ] && usage
+
+cleanup_a () {
+ for f in "${file[@]}"; do
+ rm -f "$f.new" "$f.old"
+ done
+}
+trap cleanup_a EXIT INT QUIT TERM
+
+for f in "${file[@]}"; do "$@" <"$f" >"$f.new"; done
+for f in "${file[@]}"; do cp "$f" "$f.old"; done
+
+cleanup_b () {
+ for f in "${file[@]}"; do
+ rm -f "$f.new"
+ mv "$f.old" "$f"
+ done
+}
+trap cleanup_b EXIT INT QUIT TERM
+
+for f in "${file[@]}"; do mv "$f.new" "$f"; done
+trap '' EXIT INT QUIT TERM
+for f in "${file[@]}"; do rm -f "$f.old"; done
+exit 0
--- /dev/null
+.de VS
+.sp 1
+.RS
+.nf
+.ft B
+..
+.de VE
+.ft R
+.fi
+.RE
+.sp 1
+..
+.TH inplace 1 "5 February 2005" "Edgeware tools"
+.SH NAME
+inplace \- update a file in-place
+.SH SYNOPSIS
+.B inplace
+.I file
+...
+.B \-\-
+.I program
+.RI [ arguments ...]
+.SH DESCRIPTION
+The
+.B inplace
+program rewrites files in place using filters. For each
+.I file
+it runs
+.VS
+.IR "program arguments " ...
+.VE
+with standard input redirected from
+.I file
+and redirecting standard output to
+.IR file \c
+.BR .new .
+If all these programs are successful, then each
+.I file
+is copied to
+.IB file .old
+and each
+.IB file .new
+renamed to
+.IR file ;
+the
+.IB file .old
+files are then deleted. If something went wrong, the
+.IB file .new
+files are all deleted and the original
+.IR file s
+are left unmodified.
+.I program
+exits successfully,
+.B inplace
+will rename the newly-written
+.IB file .new
+to simply
+.I file
+and exit zero; otherwise it deletes
+.IB file .new
+and exits the same as
+.I program
+did.
+.SH BUGS
+Doesn't exit correctly if subprogram was killed by a signal. The update
+isn't completely perfect but it's very good; it can leave debris lying
+around if strange things happen during the renaming.
+.SH AUTHOR
+Mark Wooding (mdw@nsict.org).
The decompressed versions of files are always created with default
owner, group and permissions (as set by the current euid, egid and umask
settings).
+.PP
+It doesn't leave file extensions on the decompressed files.
.SH AUTHOR
Mark Wooding (mdw@nsict.org).