#cloud-config
# vim: syntax=yaml
#
# This configuration file sets up an environment to perforam DELPHI analysis and simulation.
# For more information on the format of this script see the cloud-config documentation:
#
#   https://cloudinit.readthedocs.io
#
# The password of the delphi user is delphi2001, 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: delphi
    passwd: $6$yoWffnGi$N2avPJbvvqlOdLgYMlJSdMDrUZoigqwl8OT8KyPkj4pROlgbJ4qrFbl5803kAWzfmwUl7LjqkrZ98M8euNRlR/
    ssh-authorized-keys:
      - [your ssh public key]
    shell: /bin/bash

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=delphi.cern.ch
    path: /etc/cvmfs/default.local
-   content: |
      CVMFS_SERVER_URL=http://cvmfs-delphi.cern.ch/cvmfs/delphi.cern.ch
      CVMFS_PUBLIC_KEY=/etc/cvmfs/keys/delphi.cern.ch.pub
    path: /etc/cvmfs/config.d/delphi.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/delphi.cern.ch.pub
-   content: |
      # .bashrc

      # Source global definitions
      if [ -f /etc/bashrc ]; then
      	. /etc/bashrc
      fi

      # User specific aliases and functions
      source /cvmfs/delphi.cern.ch/pro/profiles/delphi.sh
    path: /home/delphi/.bashrc
-   content: |
      source /cvmfs/delphi.cern.ch/pro/profiles/delphi.csh
    path: /home/delphi/.tcshrc
-   content: |
      To get access to the DELPHI data identify yourself using kerberos:

            kinit <account>@CERN.CH

      Where <account> is your CERN account. The account needs to be on the
      DELPHI e-group. Please see more on the topic at the DPHEP Portal:

          http://cern.ch/dphep/content/delphi

      Once you have authenticated yourself you will be able to access the
      data at: /eos/experiment/delphi/

      The DELPHI code is in: /cvmfs/delphi.cern.ch/

      The delphi account is set to use bash but tcsh is also supported, the
      .bashrc and .tcshrc will set up the DELPHI environment for you. You
      can find some examples in

          /cvmfs/delphi.cern.ch/pro/testjobs/

      Have fun!
    path: /etc/motd

runcmd:
  - [chkconfig, eosd, on]
  - [service, eosd, start]
  - [chown, -R, "delphi:delphi", /home/delphi]
