Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

WIP swan script for etcprofile #80

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions etc/profile.d/swan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export LD_LIBRARY_PATH=/usr/local/lib/
SRCTMP=`mktemp`
#to make krb5 work, temporary
source <(grep KRB5CCNAME /scratch/rcastell/.bash_profile )
/usr/local/bin/python3 -E << EOF
from pathlib import Path
envtowrite=[]
for p in [Path.cwd(), *Path.cwd().parents]:
print(p)
try:
with open(p / ".swanproject") as f:
print(f'reading file from {p}')
for line in f.readlines():
name, value = line.rstrip("\n").split("=", 1)
envtowrite.append(f'export {name}={value}\n')
with open("$SRCTMP",'w') as f:
f.writelines(envtowrite)
break
except PermissionError as e:
## it means we are out of the hierarchy
break
except FileNotFoundError as e:
## this folder doesn't contain a .swanproject file
pass
EOF

if [ $? -eq 0 ];
then
source $SRCTMP;
else
echo 'no env file set';
source /scratch/rcastell/.bash_profile
fi