# profile-requires: screen.bashrc
# XXX: Use a module.
tmux=$(PATH=$PATH:/comm/tmux/stable/bin find_working tmux 2>/dev/null)
+krenew=$(PATH=$PATH:/comm/kstart/stable/bin find_working krenew 2>/dev/null)
if [ $? = 0 ]; then
- alias session="bigtmux $tmux has -t session 2>/dev/null && tmux attach -t session || ktmux -T $tmux -s session"
+ alias session="bigtmux $tmux has -t session 2>/dev/null && tmux attach -t session || ktmux -R $krenew -T $tmux -s session"
if [ -n "$TMUX" ]; then
- $tmux run-shell ktmux_helper ';' detach 2>/dev/null
+ $tmux run-shell "ktmux_helper -R $krenew" ';' detach 2>/dev/null
fi
fi
+unset krenew tmux
#!/bin/bash
+#
+# ktmux: Start tmux and ktmux_helper.
+# Usage: ktmux [options]
+# Options: -I <path> Pass path to kinit through to ktmux_helper.
+# -L <path> Pass path to klist through to ktmux_helper.
+# -R <path> Pass path to krenew through to ktmux_helper.
+# -T <path> Path to tmux.
+# -n <name> Window name for new tmux session.
+# -s <name> Session name for new tmux session.
+# -t <name> Target session name for new tmux session.
+#
tmux=tmux
+helper_opts=
tmux_opts=
session_opts=
-while getopts ":T:n:s:t:" opt; do
+while getopts ":I:L:R:T:n:s:t:" opt; do
case $opt in
+ I|L|R) helper_opts="$helper_opts -$opt $OPTARG";;
T) tmux="$OPTARG";;
n|s|t) session_opts="$session_opts -$opt $OPTARG";;
esac
fi
klist -s || kinit
-exec $tmux ${tmux_opts## } new-session ${session_opts## } -d ';' set-environment KRB5CCNAME "$KRB5CCNAME" ';' attach ';' run-shell ktmux_helper
+exec $tmux ${tmux_opts## } new-session ${session_opts## } -d ';' set-environment KRB5CCNAME "$KRB5CCNAME" ';' attach ';' run-shell "ktmux_helper ${helper_opts## }"
#!/usr/bin/perl
#
# ktmux_helper: Run krenew in the background for tmux.
+# Usage: ktmux_helper [options]
+# Options: -I <path> Specify path to kinit.
+# -L <path> Specify path to klist.
+# -R <path> Specify path to krenew.
# Notes: Doesn't handle multiple sessions properly.
#
use FindBin;
+use Getopt::Std;
use POSIX ":sys_wait_h";
my $PROG = $FindBin::Script;
exit 0 if $tmux_helper;
$tmux_helper = $$;
+my %opts;
+getopts('I:L:R:', \%opts);
+
+my $kinit = $opts{'I'} || "kinit";
+my $klist = $opts{'L'} || "klist";
+my $krenew = $opts{'R'} || "krenew";
+
my $exitasap = 0;
my $pid = 0;
}
else {
exit 1 if &check_credentials;
- exec "krenew", "-K", "60";
+ exec $krenew, "-K", "60";
print "$PROG: Can't run krenew: $!\n";
exit 111;
}
# Try to check existing Kerberos credentials.
sub check_credentials {
- system "klist", "-s";
+ system $klist, "-s";
return 1 if $? < 0;
return 0 unless $?;
kill USR1, $tmux_helper;
sub want_credentials {
# Do we already know?
return sleep 1 if &check_kinit_child;
- system "tmux", "new-window", "-n", "Renew Kerberos credentials", "exec kinit";
+ system "tmux", "new-window", "-n", "Renew Kerberos credentials", "exec $kinit";
}
sub cleanup {