-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: tool to run kinit/aklog for you if needed (#147)
- 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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |