chiark / gitweb /
Templates for scripts. Monitoring script. Do not depend on time of generation at...
[vinegar-ip.git] / Makefile
index 15f0ea8908118c4ccd6af81f549bc7a523fda90e..8f4acce3e134ec491483640c6785ea41f9e831c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,9 @@ PARTS=                100
 # You shouldn't need to edit anything beyond this point.
 #############################################################
 
-FEW_TARGETS=   on-dest.sh \
+SCRIPT_TARGETS=        on-dest.sh monitor.sh
+
+FEW_TARGETS=   $(SCRIPT_TARGETS) \
                send-1.pcap send-1.log send-1.why
 
 TARGETS=       $(FEW_TARGETS) \
@@ -64,12 +66,18 @@ AN_TARGETS= $(AN_LOGS) $(AN_DIFFS)
 INFORM=                @echo ' GENERATED THESE FILES:'; \
                echo '          $^'
 
+SOURCE_IP=     $(shell expr $(SOURCE) : '\([0-9.]*\)/')
+DEST_IP=       $(shell expr $(DEST) : '\([0-9.]*\)/')
+
 all:           $(TARGETS)
                        $(INFORM)
 
 few:           $(FEW_TARGETS)
                        $(INFORM)
 
+scripts:       $(SCRIPT_TARGETS)
+                       $(INFORM)
+
 anal analyse:  $(AN_TARGETS)
                        $(INFORM)
 
@@ -87,7 +95,7 @@ send-all.why: $(A_WHYS) Makefile
 send-%.pcap send-%.why:        ./make-probes.tcl Makefile
        ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
                --source $(SOURCE) \
-               --dest $(DEST) \
+               --dest $(DEST) \
                 --xseed "$* $(UNIQUE)" >send-$*.why
 
 %.log:         %.pcap lnumber-tcpdump.pl Makefile
@@ -98,16 +106,13 @@ send-%.pcap send-%.why:    ./make-probes.tcl Makefile
 recv-%.diff:   send-%.log recv-%.log
                diff -uI'^[0-9]' $^ >$@ || test $$? == 1
 
-on-dest.sh:    Makefile
-       @rm -f $@
-       echo >$@ "#!/bin/sh"
-       @echo >>$@ "# run this script on $(DEST) as root, saying:"
-       @echo >>$@ "#   ./on-dest.sh PART"
-       @echo >>$@ "# where PART ranges from 1 to $(PARTS)"
-       @echo >>$@ "if ! [ \$$# = 1 ]; then echo >&2 'PART?'; exit 1; fi"
-       @echo >>$@ "exec tcpdump -s$$(($(MTU)+500)) -w recv-\$$1.pcap \\"
-       @echo >>$@ " src host $(SOURCE) and dst host $(DEST)"
-       chmod +x $@
+%.sh:          %.template Makefile
+               sed <$< >$@.tmp -e ' \
+                       s/@@M/'$$(($(MTU)+500))'/; \
+                       s/@@S/$(SOURCE_IP)/; \
+                       s/@@D/$(DEST_IP)/'
+               chmod +x $@.tmp
+               @mv -f $@.tmp $@
 
 clean:
                rm -f *.tmp *~ t u v