|
|
1.1 root 1: #! /bin/sh -
2:
3: umask 022
4:
5: LDIR=%LDIR%
6: SDIR=%SDIR%
7: QPREFIX=Q.
8:
9: PATH=$LDIR:/bin:/usr/bin:/usr/ucb:/usr/bsd
10: export PATH
11:
12: DEST=$LDIR/destinations
13:
14: showq=0
15: recv=0
16: notify=0
17: systems=
18: usage='usage: dist [-q|-r] [system|-[Ff] file] [-n] [files...]'
19:
20: while [ $# -gt 0 ]
21: do
22: case "$1" in
23: -q)
24: showq=1
25: ;;
26: -r)
27: recv=1
28: ;;
29: -n)
30: notify=1
31: ;;
32: -[Ff])
33: if [ $# -lt 2 ]
34: then
35: echo "$usage" 1>&2
36: exit 1
37: fi
38: if [ x$1 = x-f -a -r "$2" ]
39: then
40: systems=`cat "$2" 2>/dev/null`
41: elif [ -r $DEST/"$2" ]
42: then
43: systems=`cat $DEST/"$2" 2>/dev/null`
44: else
45: echo "dist: can't open '$2'" 1>&2
46: exit 1
47: fi
48: shift
49: ;;
50: -*)
51: echo "dist: unknown flag '$1'" 1>&2
52: exit 1
53: ;;
54: *)
55: if [ "x$systems" != x ]
56: then
57: break
58: fi
59: systems="$1"
60: ;;
61: esac
62: shift
63: done
64:
65: if [ $recv = 1 ]
66: then
67: if [ x"$systems" = x ]
68: then
69: echo dist: no systems specified 1>&2
70: exit 1
71: else
72: for sys in $systems
73: do
74: echo $sys:
75: connect $sys transmit io receive || exit 1
76: done
77: exit 0
78: fi
79: fi
80:
81: if [ $showq = 1 ]
82: then
83: if [ x"$systems" = x ]
84: then
85: showq
86: exit 0
87: else
88: for sys in $systems
89: do
90: echo $sys:
91: connect $sys showq i /bin/cat
92: done
93: exit 0
94: fi
95: fi
96:
97: if [ $# = 0 ]
98: then
99: echo "$usage" 1>&2
100: exit 1
101: fi
102:
103: # construct spool directory
104: for d in `echo $$ | awk '{for (i = 0; i < 1000; ++i) printf "%03d%d\n", i, $1}'`
105: do
106: if [ ! -f $SDIR/$QPREFIX$d ]
107: then
108: dir=$QPREFIX$d
109: mkdir $SDIR/$dir && break
110: echo "dist: can't make spool directory" 1>&2
111: exit 1
112: fi
113: done
114:
115: data=$SDIR/$dir/data
116: ctl=$SDIR/$dir/tempctl
117: files=$SDIR/$dir/files
118:
119: # use canonical system names.
120: canon $systems | awk '{for (i = 1; i <= NF; ++i) printf "%d %s\n", ++n, $i}' > $ctl
121:
122: mkpkg "$@" > $data
123:
124: pwd=`pwd`
125: for f in "$@"
126: do
127: case "$f" in
128: -*) # flag to mkpkg
129: ;;
130: /*)
131: echo "$f"
132: ;;
133: *)
134: echo "$pwd/$f"
135: ;;
136: esac
137: done | sort > $files
138:
139: # rename the ctl file to its real name; at this point the package
140: # is now available for shipment.
141: mv $ctl $SDIR/$dir/ctl
142:
143: # supersede old jobs containing the same files
144: cd $SDIR
145: for d in $QPREFIX*
146: do
147: test $d = $dir && continue
148: test -w $d || continue
149: if [ `comm -23 $d/files $dir/files | wc -c` = 0 ]
150: then
151: sort +1 $d/ctl $dir/ctl | uniq -d -2 |
152: while read num sys
153: do
154: echo superseded by $dir > $d/$num.done
155: done
156: fi
157: done
158:
159: # clean up any jobs we completely superseded.
160: cleanq
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.