Add pag-screen script
authorAlex Dehnert <adehnert@mit.edu>
Fri, 28 May 2010 07:34:49 +0000 (03:34 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Fri, 25 Jun 2010 08:07:15 +0000 (04:07 -0400)
Based on owl-screen (from kchen), this creates a screen in a new PAG
with a new kerberos ticket cache.

Makefile
pag-screen [new file with mode: 0755]

index 1aab0b7752a97e361030168c59843848cc217e88..513f288679cd605d4bc2f9031ad5c20c3b3b23af 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 archdir=/mit/$(ATHENA_USER)/arch/
 common=$(archdir)/common/
-scripts=bores-me  card-access  grep-owners  ldapfinger list-members  list-of-lists-updater  lists-lint  rt-set  rt-resolve check-host  update-officers make-zcrypt-key get-emails  mail-merge  sshroot
+scripts=bores-me  card-access  grep-owners  ldapfinger list-members  list-of-lists-updater  lists-lint  rt-set  rt-resolve check-host  update-officers make-zcrypt-key get-emails  mail-merge  sshroot pag-screen
 arches=i386_deb31  i386_deb40  i386_deb50  i386_rhel4
 
 all : install
diff --git a/pag-screen b/pag-screen
new file mode 100755 (executable)
index 0000000..2fc538d
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/env pagsh
+
+screen=`which screen`
+
+# Check for pre-existing screens.
+screenlist=`$screen -list | grep owl`
+if [ "x$screenlist" != "x" ]; then
+    echo "Found a pre-existing owl-screen session:"
+    echo "$screenlist"
+    echo "You probably want to reattach it instead."
+    echo
+    exit 1
+fi
+
+# Get AFS tokens for the screen session.
+# We are now in a new PAG (because of pagsh).
+# If you want to get tokens for other cells, list them in ~/.xlog
+aklog
+
+# Use separate kerberos tickets for screen. Even if we accidentally
+# (or intentionally) log out, screen and owl will still have tickets.
+NEWKRB5=/tmp/krb5cc_${USER}_screen
+
+# Copy the tickets we obtained on login to the screen tickets.
+KRB5CCNAME=`echo $KRB5CCNAME | sed 's/FILE://'`
+cp $KRB5CCNAME $NEWKRB5
+
+# Now actually use the new tickets.
+KRB5CCNAME=FILE:$NEWKRB5; export KRB5CCNAME
+
+# Repeat for krb4 if appropriate.
+if [ "x$KRBTKFILE" != "x" ]; then
+   NEWKRB4=/tmp/tkt_${USER}_screen
+   KRBTKFILE=`echo $KRBTKFILE | sed 's/FILE://'`
+   cp $KRBTKFILE $NEWKRB4
+   KRBTKFILE=$NEWKRB4; export KRBTKFILE
+fi
+
+# Figure out which zephyr client to use.  Defaults to barnowl.
+if [ "x$ZEPHYR_SCREEN_CLIENT" = "x" ]; then
+    barnowl=`which barnowl`
+    if [ ! -x "$barnowl" ]; then
+       attach -n -q barnowl
+       barnowl=`athdir /mit/barnowl`/barnowl
+    fi
+    ZEPHYR_SCREEN_CLIENT="$barnowl"
+fi
+
+# Renew tickets and tokens.
+contrenew=`which cont-renew-notify`
+if [ ! -x "$contrenew" ]; then
+    zwrite $ATHENA_USER -d -m "$0: cont-renew doesn't exist on $(hostname)... Not doing renewals"
+    contrenew=/bin/true
+fi
+nohup $contrenew < /dev/null > /dev/null 2> /dev/null &
+
+# Name the screen pag so we can reattach the right screen later.
+$screen -S pag