#!/usr/bin/env pagsh # I have no idea what I'm doing # Copyright (c) 2004-2012 Kevin Chen # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. tmux=`which tmux` if [ ! -x "$tmux" ]; then echo "no tmux, gg" exit 1 fi if [ "x$TMUX_SESSION_NAME" = "x" ]; then TMUX_SESSION_NAME="owl" fi # Check for pre-existing tmuxes. tmuxlist=`$tmux list-sessions | grep "^$TMUX_SESSION_NAME"` if [ "x$tmuxlist" != "x" ]; then echo "Found a pre-existing $TMUX_SESSION_NAME-tmux session:" echo "$tmuxlist" echo "You probably want to reattach it instead." echo exit 1 fi # Get AFS tokens for the tmux 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 tmux. Even if we accidentally # (or intentionally) log out, the tmux session will still have # tickets. NEWKRB5=`mktemp -t "krb5cc_${USER}_tmux_XXXXXXXXXX"` # Copy the tickets we obtained on login to the tmux 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=`mktemp -t "tkt_${USER}_tmux_XXXXXXXXXX"` 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_TMUX_CLIENT" = "x" ]; then barnowl=`which barnowl` if [ ! -x "$barnowl" ]; then attach -n -q barnowl barnowl=`athdir /mit/barnowl`/barnowl fi ZEPHYR_TMUX_CLIENT="$barnowl" fi # Renew tickets and tokens. contrenew=`which cont-renew-notify` if [ ! -x "$contrenew" ]; then attach -n -q kchen contrenew=`athdir /mit/kchen`/cont-renew-notify fi nohup $contrenew < /dev/null > /dev/null 2> /dev/null & # Name the tmux $TMUX_SESSION_NAME so we can reattach the right # tmux later. $tmux new-session -s $TMUX_SESSION_NAME $ZEPHYR_TMUX_CLIENT