Skip to content

Commit

Permalink
DEV: tool to run kinit/aklog for you if needed (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaushik Malapati authored and Kaushik Malapati committed Oct 11, 2023
1 parent e1156a9 commit 4ee638b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/kinit_helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

function kauth {
# If token doesn't exist, create it (will query for password)
if ! klist -s
then
while ! kinit
do
:
done
fi
}

function afsauth {
# afs needs kerberos token
kauth
# only available on psbuild servers
if [[ $(hostname) != psbuild-rhel* ]]
then
echo "You must be on psbuild to create afs tokens"
exit
fi

# need to be in g-pcds afs grup
if ! pts membership g-pcds 2>&1 | grep -q "$(whoami)"
then
echo "You do not have permission to use afs. See https://confluence.slac.stanford.edu/display/PCDS/Onboarding+Staff+Members"
exit
fi

# If token doesn't exist, create it
if ! tokens | grep -q $UID
then
aklog
fi
}

# if name == '__main__':
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
afsauth
fi

0 comments on commit 4ee638b

Please sign in to comment.