configure.sh 2.17 KB
Newer Older
1
#!/bin/bash
Fabio Hernandez's avatar
Fabio Hernandez committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

# Configure this machine as a CernVM FS client to access LSST
# software repository served by CC-IN2P3.
# This script can be run multiple times.
# More information: https://github.com/airnandez/lsst-cvmfs

# We must run as 'root'
if [ "$EUID" -ne 0 ]; then
    echo "Please run as root"
    exit 1
fi

# Run CernVM FS configuration
if [ ! -x /usr/bin/cvmfs_config ]; then
    echo "Could not find CernVM FS configuration tool"
    exit 1
fi
/usr/bin/cvmfs_config setup
20 21 22
if [ $? -ne 0 ]; then
    exit 1
fi
Fabio Hernandez's avatar
Fabio Hernandez committed
23 24 25 26

# Configure CernVM FS
# WARNING: make sure we don't overwrite any existing configuration, different
# than ours
27 28 29 30
localConfig="/etc/cvmfs/default.local"
if [ -e ${localConfig} ]; then
    repos=`grep CVMFS_REPOSITORIES ${localConfig} | sed s/CVMFS_REPOSITORIES=//g`
    if [ -n $repos ] && [ $repos != "lsst.in2p3.fr" ]; then
Fabio Hernandez's avatar
Fabio Hernandez committed
31
        echo "CernVM FS seems to be already configured in this machine in a potentially incompatible way"
Fabio Hernandez's avatar
Fabio Hernandez committed
32 33 34 35
        echo "see file /etc/cvmfs/default.local"
        exit 1
    fi
fi
36 37
cp default.local /etc/cvmfs/default.local && \
    chmod 0644 /etc/cvmfs/default.local
Fabio Hernandez's avatar
Fabio Hernandez committed
38 39

# Configure the LSST repository and store its public key
40 41
cp lsst.in2p3.fr.conf /etc/cvmfs/config.d/lsst.in2p3.fr.conf && \
    chmod 0644 /etc/cvmfs/config.d/lsst.in2p3.fr.conf
Fabio Hernandez's avatar
Fabio Hernandez committed
42

43 44 45 46 47 48
rm -f /etc/cvmfs/keys/lsst.in2p3.fr.pub
mkdir -p /etc/cvmfs/keys/in2p3.fr && \
    cp lsst.in2p3.fr.pub /etc/cvmfs/keys/in2p3.fr/lsst.in2p3.fr.pub && \
    chmod 0444 /etc/cvmfs/keys/in2p3.fr/lsst.in2p3.fr.pub

# Perform system-specific tasks
Fabio Hernandez's avatar
Fabio Hernandez committed
49 50
thisOS=`uname`
if [ "$thisOS" == "Linux" ]; then
51 52 53
    # Make /etc/cvmfs/domain.d to make 'cvmfs_config' happy
    mkdir -p /etc/cvmfs/domain.d

54
    # Use 'cvmfs_config' to check the configuration
Fabio Hernandez's avatar
Fabio Hernandez committed
55 56 57 58 59 60
    result=`/usr/bin/cvmfs_config chksetup`
    if [ "$result" != "OK" ]; then
        echo "There was an error checking your CernVM FS configuration:"
        echo $result
        exit 1
    fi
61

62
    # Restart autofs
Fabio Hernandez's avatar
Fabio Hernandez committed
63 64 65 66 67
    service autofs restart > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "Could not restart autofs service"
        exit 1
    fi
68 69 70
elif [ "$thisOS" == "Darwin" ]; then
    # On MacOS X, create the mount directory
    mkdir -p /cvmfs/lsst.in2p3.fr
Fabio Hernandez's avatar
Fabio Hernandez committed
71 72 73 74
fi

# Done
exit 0