⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ RUN chmod 0644 /etc/cron.d/*
COPY cms-xcache/image-config.d/* /etc/osg/image-init.d/
COPY cms-xcache/xcache-consistency-check-wrapper.sh /usr/bin/xcache-consistency-check-wrapper.sh
COPY cms-xcache/rsyslog-cms-xcache.conf /etc/rsyslog.d/cms-xcache.conf
COPY cms-xcache/sbin/* /usr/local/sbin/
RUN chmod 0544 /usr/local/sbin/fetch_scitoken.sh

RUN mkdir -p /var/log/xrootd/cms-xcache && \
touch /var/log/xrootd/cms-xcache/xrootd.log && \
Expand Down
2 changes: 2 additions & 0 deletions cms-xcache/cron.d/fetch-scitoken
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@reboot root /usr/local/sbin/fetch_scitoken.sh &>> /tmp/fetch-cms-scitoken.cron.log
0 */6 * * * root /usr/local/sbin/fetch_scitoken.sh &>> /tmp/fetch-cms-scitoken.cron.log
25 changes: 25 additions & 0 deletions cms-xcache/sbin/fetch_scitoken.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if [ -f /etc/grid-security/fetch_scitoken_secret ]; then
USER=`cat /etc/grid-security/fetch_scitoken_secret | awk -F ":" '{print $1}'`
PASS=`cat /etc/grid-security/fetch_scitoken_secret | awk -F ":" '{print $2}'`

if [[ -z "$USER" || -z "$PASS" ]]; then
echo "Wrong format in secret file"
exit 1
fi

curl -s --user $USER:$PASS -d grant_type=client_credentials -d scope="storage.read:/" https://cms-auth.cern.ch/token \
| python3 -c 'import sys,json; print(json.loads(sys.stdin.read())["access_token"])' > /tmp/jwt_xrdcache

if [ $? -ne 0 ]; then
echo "Failed to retrieve token"
exit 2
fi

chown xrootd: /tmp/jwt_xrdcache
chmod 600 /tmp/jwt_xrdcache

else
echo "Secret file not found"
fi
2 changes: 1 addition & 1 deletion cms-xcache/supervisord.d/10-cms-xcache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
command=xrootd -c /etc/xrootd/xrootd-cms-xcache.cfg -k fifo -n cms-xcache -k %(ENV_XC_NUM_LOGROTATE)s -s /var/run/xrootd/xrootd-cms-xcache.pid -l /var/log/xrootd/xrootd.log
user=xrootd
autorestart=true
environment=LD_PRELOAD=/usr/lib64/libtcmalloc.so,TCMALLOC_RELEASE_RATE=10
environment=LD_PRELOAD=/usr/lib64/libtcmalloc.so,TCMALLOC_RELEASE_RATE=10,BEARER_TOKEN_FILE=/tmp/jwt_xrdcache,XrdSecPROTOCOL="ztn"