summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/misc
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/upas/misc
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/upas/misc')
-rwxr-xr-xsys/src/cmd/upas/misc/go.fishing15
-rwxr-xr-xsys/src/cmd/upas/misc/gone.fishing19
-rwxr-xr-xsys/src/cmd/upas/misc/gone.msg6
-rwxr-xr-xsys/src/cmd/upas/misc/mail12
-rwxr-xr-xsys/src/cmd/upas/misc/mkfile35
-rwxr-xr-xsys/src/cmd/upas/misc/namefiles2
-rwxr-xr-xsys/src/cmd/upas/misc/qmail6
-rwxr-xr-xsys/src/cmd/upas/misc/remotemail7
-rwxr-xr-xsys/src/cmd/upas/misc/rewrite20
-rwxr-xr-xsys/src/cmd/upas/misc/unix/gone.fishing.sh9
-rwxr-xr-xsys/src/cmd/upas/misc/unix/mail.c51
-rwxr-xr-xsys/src/cmd/upas/misc/unix/mail.sh12
-rwxr-xr-xsys/src/cmd/upas/misc/unix/makefile44
13 files changed, 238 insertions, 0 deletions
diff --git a/sys/src/cmd/upas/misc/go.fishing b/sys/src/cmd/upas/misc/go.fishing
new file mode 100755
index 000000000..8035fe045
--- /dev/null
+++ b/sys/src/cmd/upas/misc/go.fishing
@@ -0,0 +1,15 @@
+#!/bin/rc
+# go.fishing - set up vacation responder
+rfork e
+
+cd /mail/box/$user
+if (test -e gone.fishing) {
+ echo $0: /mail/box/$user/gone.fishing already exists >[1=2]
+ exit 'already fishing'
+}
+
+>gone.addrs
+chmod -a gone.addrs
+>gone.addrs
+chmod +arw gone.addrs
+>>gone.fishing
diff --git a/sys/src/cmd/upas/misc/gone.fishing b/sys/src/cmd/upas/misc/gone.fishing
new file mode 100755
index 000000000..66fb10bcf
--- /dev/null
+++ b/sys/src/cmd/upas/misc/gone.fishing
@@ -0,0 +1,19 @@
+#!/bin/rc
+# gone.fishing local!$user /mail/box/$user/mbox - vacation responder
+# as pipeto script
+
+# standard library. saves the message on standard input in $TMP.msg and
+# parses it into /mail/fs/mbox/1.
+. /mail/lib/pipeto.lib $*
+
+{cat $TMP.msg; echo} >>/mail/box/$USER/gone.mail
+
+message=/mail/box/$USER/gone.msg
+if (! test -e $message)
+ message=/mail/lib/gone.msg
+
+MAILTO=`{cat $D/replyto}
+grep '^'$"MAILTO'$' /mail/box/$USER/gone.addrs >/dev/null >[2=1] || {
+ echo $MAILTO >>/mail/box/$USER/gone.addrs
+ mail $MAILTO <$message
+}
diff --git a/sys/src/cmd/upas/misc/gone.msg b/sys/src/cmd/upas/misc/gone.msg
new file mode 100755
index 000000000..ac1e7bd9e
--- /dev/null
+++ b/sys/src/cmd/upas/misc/gone.msg
@@ -0,0 +1,6 @@
+subject: away from my computer
+
+This is a recorded message. I am currently out of contact with my
+computer system. Your message to me has been saved and will be
+read upon my return. This is the last time you will receive this
+message during my absence. Thank you.
diff --git a/sys/src/cmd/upas/misc/mail b/sys/src/cmd/upas/misc/mail
new file mode 100755
index 000000000..6913d743e
--- /dev/null
+++ b/sys/src/cmd/upas/misc/mail
@@ -0,0 +1,12 @@
+#!/bin/rc
+switch($#*){
+case 0
+ exec upas/nedmail
+}
+
+switch($1){
+case -f* -r* -c* -m*
+ exec upas/nedmail $*
+case *
+ exec upas/marshal $*
+}
diff --git a/sys/src/cmd/upas/misc/mkfile b/sys/src/cmd/upas/misc/mkfile
new file mode 100755
index 000000000..0fa970e17
--- /dev/null
+++ b/sys/src/cmd/upas/misc/mkfile
@@ -0,0 +1,35 @@
+RCFILES=mail\
+ go.fishing\
+
+all:VQ:
+ ;
+
+installall:VQ: install
+ ;
+
+install:V: mail go.fishing gone.msg gone.fishing
+ cp mail go.fishing /rc/bin
+ cp gone.msg gone.fishing /mail/lib
+
+safeinstall:V: install
+
+safeinstallall:V: install
+
+clean:VQ:
+ ;
+nuke:V:
+ ; # rm /rc/bin/^(mail gone.fishing)
+
+UPDATE=\
+ go.fishing\
+ gone.fishing\
+ gone.msg\
+ mail\
+ mkfile\
+ namefiles\
+ qmail\
+ remotemail\
+ rewrite\
+
+update:V:
+ update $UPDATEFLAGS $UPDATE
diff --git a/sys/src/cmd/upas/misc/namefiles b/sys/src/cmd/upas/misc/namefiles
new file mode 100755
index 000000000..ab3853b1c
--- /dev/null
+++ b/sys/src/cmd/upas/misc/namefiles
@@ -0,0 +1,2 @@
+names.local
+names.global
diff --git a/sys/src/cmd/upas/misc/qmail b/sys/src/cmd/upas/misc/qmail
new file mode 100755
index 000000000..77a3d228a
--- /dev/null
+++ b/sys/src/cmd/upas/misc/qmail
@@ -0,0 +1,6 @@
+#!/bin/rc
+sender=$1
+shift
+addr=$1
+shift
+qer /mail/queue mail $sender $addr $* && runq /mail/queue /mail/lib/remotemail
diff --git a/sys/src/cmd/upas/misc/remotemail b/sys/src/cmd/upas/misc/remotemail
new file mode 100755
index 000000000..312ee5874
--- /dev/null
+++ b/sys/src/cmd/upas/misc/remotemail
@@ -0,0 +1,7 @@
+#!/bin/rc
+shift
+sender=$1
+shift
+addr=$1
+shift
+/bin/upas/smtp -g research.research.bell-labs.com $addr $sender $*
diff --git a/sys/src/cmd/upas/misc/rewrite b/sys/src/cmd/upas/misc/rewrite
new file mode 100755
index 000000000..fd724eb1e
--- /dev/null
+++ b/sys/src/cmd/upas/misc/rewrite
@@ -0,0 +1,20 @@
+# case conversion for postmaster
+pOsTmAsTeR alias postmaster
+
+# local mail
+[^!@]+ translate "/bin/upas/aliasmail '&'"
+local!(.*) >> /mail/box/\1/mbox
+\l!(.*) alias \1
+(helix|helix.bell-labs.com)!(.*) alias \2
+
+# we can be just as complicated as BSD sendmail...
+# convert source domain address to a chain a@b@c@d...
+@([^@!,]*):([^!@]*)@([^!]*) alias \2@\3@\1
+@([^@!]*),([^!@,]*):([^!@]*)@([^!]*) alias @\1:\3@\4@\2
+
+# convert a chain a@b@c@d... to ...d!c!b!a
+([^@]+)@([^@]+)@(.+) alias \2!\1@\3
+([^@]+)@([^@]+) alias \2!\1
+
+# /mail/lib/remotemail will take care of gating to systems we don't know
+([^!]*)!(.*) | "/mail/lib/qmail '\s' 'net!\1'" "'\2'"
diff --git a/sys/src/cmd/upas/misc/unix/gone.fishing.sh b/sys/src/cmd/upas/misc/unix/gone.fishing.sh
new file mode 100755
index 000000000..a304271c0
--- /dev/null
+++ b/sys/src/cmd/upas/misc/unix/gone.fishing.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+PATH=/bin:/usr/bin
+message=${1-/usr/lib/upas/gone.msg}
+return=`sed '2,$s/^From[ ]/>&/'|tee -a $HOME/gone.mail|sed -n '1s/^From[ ]\([^ ]*\)[ ].*$/\1/p'`
+echo '' >>$HOME/gone.mail
+grep "^$return" $HOME/gone.addrs >/dev/null 2>/dev/null || {
+ echo $return >>$HOME/gone.addrs
+ mail $return < $message
+}
diff --git a/sys/src/cmd/upas/misc/unix/mail.c b/sys/src/cmd/upas/misc/unix/mail.c
new file mode 100755
index 000000000..20cf23970
--- /dev/null
+++ b/sys/src/cmd/upas/misc/unix/mail.c
@@ -0,0 +1,51 @@
+/*
+ * #!/bin/sh
+ * case $1 in
+ * -n)
+ * exit 0 ;;
+ * -m*|-f*|-r*|-p*|-e*|"")
+ * exec /usr/lib/upas/edmail $*
+ * exit $? ;;
+ * *)
+ * exec /usr/lib/upas/send $*
+ * exit $? ;;
+ * esac
+ */
+
+
+extern *UPASROOT;
+
+#define EDMAIL "edmail"
+#define SEND "send"
+
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *progname = SEND;
+ char realprog[500];
+
+ if (argc > 1) {
+ if (argv[1][0] == '-') {
+ switch (argv[1][1]) {
+ case 'n':
+ exit (0);
+
+ case 'm':
+ case 'f':
+ case 'r':
+ case 'p':
+ case 'e':
+ case '\0':
+ progname = EDMAIL;
+ }
+ }
+ } else
+ progname = EDMAIL;
+
+ sprint(realprog, "%s/%s", UPASROOT, progname);
+ execv (realprog, argv);
+ perror (realprog);
+ exit (1);
+}
+
diff --git a/sys/src/cmd/upas/misc/unix/mail.sh b/sys/src/cmd/upas/misc/unix/mail.sh
new file mode 100755
index 000000000..a41519aef
--- /dev/null
+++ b/sys/src/cmd/upas/misc/unix/mail.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+case $1 in
+-n)
+ exec LIBDIR/notify
+ exit $? ;;
+-m*|-f*|-r*|-p*|-e*|"")
+ exec LIBDIR/edmail $*
+ exit $? ;;
+*)
+ exec LIBDIR/send $*
+ exit $? ;;
+esac
diff --git a/sys/src/cmd/upas/misc/unix/makefile b/sys/src/cmd/upas/misc/unix/makefile
new file mode 100755
index 000000000..e00c4f7e8
--- /dev/null
+++ b/sys/src/cmd/upas/misc/unix/makefile
@@ -0,0 +1,44 @@
+LIB=/usr/lib/upas
+CFLAGS=${UNIX} -g -I. -I../libc -I../common -I/usr/include -I/usr/include/sys
+LFLAGS=-g
+HOSTNAME=cat /etc/whoami
+
+.c.o: ; $(CC) -c $(CFLAGS) $*.c
+all: mail
+
+sedfile:
+ echo 's+LIBDIR+$(LIB)+g' >sed.file
+ echo 's+HOSTNAME+$(HOSTNAME)+g' >>sed.file
+
+install: sedfile install.fish install.mail.sh
+
+install.fish:
+ cp gone.msg $(LIB)
+ sed -f sed.file gone.fishing >$(LIB)/gone.fishing
+ -chmod 775 $(LIB)/gone.fishing
+ -chown bin $(LIB)/gone.fishing $(LIB)/gone.msg
+
+install.mail.sh:
+ sed -f sed.file mail.sh >/bin/mail
+ -chown bin /bin/mail
+ -chmod 775 /bin/mail
+
+install.notify: notify
+ cp notify $(LIB)/notify
+ -chmod 775 $(LIB)/notify
+ -chown bin $(LIB)/notify
+
+install.mail: mail
+ cp mail /bin
+ strip /bin/mail
+
+notify: notify.o
+ cc $(LFLAGS) notify.o -o notify
+
+mail: mail.o ../config/config.o
+ cc $(LFLAGS) mail.o ../config/config.o -o mail
+
+clean:
+ -rm -f *.[oOa] core a.out *.sL notify
+ -rm -f sed.file mail
+