#cloud-config
# vim: syntax=yaml
#
# This configuration file sets up an environment to perforam OPAL analysis and reconstruction.
# For more information on the format of this script see the cloud-config documentation:
#
#   https://cloudinit.readthedocs.io
#
# The password of the opal user is opal2001, here supplied in it's hashed form. You can also
# use your public ssh key to gain access to the VM, just replace the "[your ssh public key]".

users:
  - name: opal
    passwd: $6$MHFJGHak$E7SoeG3fx3oDe1RMtiyjU8npjmI3a9zGb5/v.d3BDgKhLv/BTowUsvU8YGFgPt7Tdt/jiEifZlnNeyn3Jsgv20
    ssh-authorized-keys:
      - [your ssh public key]
    shell: /bin/tcsh

write_files:
-   content: |
      # Directory where to mount FUSE
      export EOS_FUSE_MOUNTDIR=/eos/
      # MGM URL from where to mount FUSE
      export EOS_FUSE_MGM_ALIAS=eospublic.cern.ch
    path: /etc/sysconfig/eos
-   content: |
      CVMFS_REPOSITORIES=opal.cern.ch
    path: /etc/cvmfs/default.local
-   content: |
      CVMFS_SERVER_URL=http://cvmfs-opal.cern.ch/cvmfs/opal.cern.ch
      CVMFS_PUBLIC_KEY=/etc/cvmfs/keys/opal.cern.ch.pub
    path: /etc/cvmfs/config.d/opal.cern.ch.conf
-   content: |
      -----BEGIN PUBLIC KEY-----
      MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo8uKvscgW7FNxzb65Uhm
      yr8jPJiyrl2kVzb/hhgdfN14C0tCbfFoE6ciuZFg+9ytLeiL9pzM96gSC+atIFl4
      7wTgtAFO1W4PtDQBwA/IG2bnwvNrzk19ob0JYhjZlS9tYKeh7TKCub55+vMwcEbP
      urzo3WSNCzJngiGMh1vM5iSlGLpCdSGzdwxLGwc1VjRM7q3KAd7M7TJCynKqXZPX
      R2xiD6I/p4xv39AnwphCFSmDh0MWE1WeeNHIiiveikvvN+l8d/ZNASIDhKNCsz6o
      aFDsGXvjGy7dg43YzjSSYSFGUnONtl5Fe6y4bQZj1LEPbeInW334MAbMwYF4LKma
      yQIDAQAB
      -----END PUBLIC KEY-----
    path: /etc/cvmfs/keys/opal.cern.ch.pub
-   content: |
      setenv CERN /cvmfs/opal.cern.ch/cern
      setenv CERN_LEVEL pro
      setenv CERN_ROOT $CERN/$CERN_LEVEL
      setenv PATH $CERN_ROOT/bin:$PATH
      source /cvmfs/opal.cern.ch/env/opal_env.csh
    path: /home/opal/.tcshrc
-   content: |
      To get access to the opal data identify yourself using kerberos:

            kinit <account>@CERN.CH
      
      Where <account> is your CERN account. The account needs to be on the
      OPAL e-group. Please see more on the topic at the DPHEP Portal:
      
          http://cern.ch/dphep/content/opal
      
      Once you have authenticated yourself you will be able to access the
      data at: /eos/experiment/opal/
      
      The OPAL code is in: /cvmfs/opal.cern.ch/

      The opal account is set to use tcsh, and the .tcshrc will set up the
      OPAL environment for you. You can find some examples in

          /cvmfs/opal.cern.ch/apps/examples

      To run them create a symbolic link to the data like this:

         ln -s /eos/experiment/opal/castor2015 ~/data

    path: /etc/motd

runcmd:
  - [chkconfig, eosd, on]
  - [service, eosd, start]
  - [ls, -s, /eos/experiment/opal/castor2015, /home/opal/data]
  - [chown, -R, "opal:opal", /home/opal]
