<commit_before>unique template personality/vobox/config;

# Proxy renewal interval (in hours) and log rotation parameters
variable VOBOX_PROXY_RENEWAL_INTERVAL ?= 6;
variable VOBOX_PROXY_RENEWAL_LOG_FREQUENCY ?= 'monthly';
variable VOBOX_PROXY_RENEWAL_LOG_ROTATION ?= 12;

# TCP parameters for optimal performances
variable VOBOX_TCP_MAX_BUFFER_SIZE ?= 8388608;
variable VOBOX_TCP_MAX_BACKLOG ?= 250000;

# List of directory to create in VO-specific directory.
# The following list is the minimum list: add it to site-specific defaults.
variable VOBOX_VO_DIRS_ROOT ?= EMI_LOCATION_VAR + '/lib/vobox';
variable VOBOX_VO_DIRECTORIES = {
  if ( !is_defined(SELF) || index('start',SELF) < 0 ) {
    SELF[length(SELF)] = 'start';
  };
  if ( index('stop',SELF) < 0 ) {
    SELF[length(SELF)] = 'stop';
  };
  if ( index('agents',SELF) < 0 ) {
    SELF[length(SELF)] = 'agents';
  };
  if ( index('info-provider',SELF) < 0 ) {
    SELF[length(SELF)] = 'info-provider';
  };
  if ( index('log',SELF) < 0 ) {
    SELF[length(SELF)] = 'log';
  };
  if ( index('proxy_repository',SELF) < 0 ) {
    SELF[length(SELF)] = 'proxy_repository';
  };
  SELF;
};


# Retrieve from VO_INFO the VO user enabled for access to VOBOX services.
# Normally there should be only one enabled VO, this has been checked before (personality/vobox/init)
variable VOBOX_ENABLED_VOS_USER ?= {
  foreach (i;vo;VOBOX_ENABLED_VOS) {
    if ( is_defined(VO_INFO[vo]['vobox_user']) ) {
      SELF[vo] = VO_INFO[vo]['vobox_user'];
    } else {
      debug('No FQAN allowed for VO '+vo+'. VOBOX services will not be configured for this vo');
    };
  };
  SELF;
};

# Create directories for each enable VOs
include { 'components/dirperm/config' };
'/software/components/dirperm/paths' = {
  if ( is_defined(VOBOX_ENABLED_VOS_USER) ) {
    foreach (vo;user;VOBOX_ENABLED_VOS_USER) {
      vo_dir_root = VOBOX_VO_DIRS_ROOT+'/'+vo;
      SELF[length(SELF)] = nlist('path', vo_dir_root,
                                 'perm', '0755',
                                 'owner', user,
                                 'type', 'd',
                                );
      foreach (i;dir;VOBOX_VO_DIRECTORIES) {
        SELF[length(SELF)] = nlist('path', vo_dir_root+'/'+dir,
                                   'perm', '0700',
                                   'owner', user,
                                   'type', 'd',
                                  );
      };
    };
  } else {
    debug('No FQAN allowed access to VOBOX services.');
  };
  SELF;
};


# Create proxy renewal script for each supported VO (normally only one)
# and configure related cron and logrotate.
# TODO: when filecopy will have been improved to support regexp-based
# editing of a source file already installed, this will be better to use
# the proxy renewal script installed by the RPM for easier
# synchronisation. But in lcg-vobox 1.0.4-4, the script is so buggy that
# it is unusable as is...

include { 'components/filecopy/config' };
include { 'components/chkconfig/config' };
include { 'components/cron/config' };
include { 'components/altlogrotate/config' };
'/software/components' = {
  if ( !is_defined(SELF['filecopy']['services']) ) {
    SELF['filecopy']['services'] = nlist();
  };
  if ( !is_defined(SELF['chkconfig']['service']) ) {
    SELF['chkconfig']['service'] = nlist();
  };
  if ( !is_defined(SELF['cron']['entries']) ) {
    SELF['cron']['entries'] = list();
  };
  if ( !is_defined(SELF['cron']['allow']) ) {
    SELF['cron']['allow'] = list();
  };
  if ( index('root',SELF['cron']['allow']) < 0 ) {
    SELF['cron']['allow'][length(SELF['cron']['allow'])] = 'root';
  };
  if ( !is_defined(SELF['altlogrotate']['entries']) ) {
    SELF['altlogrotate']['entries'] = nlist();
  };
  if ( index('filecopy',SELF['chkconfig']['dependencies']['pre']) < 0 ) {
    SELF['chkconfig']['dependencies']['pre'][length(SELF['chkconfig']['dependencies']['pre'])] = 'filecopy';
  };
  if ( index('filecopy',SELF['cron']['dependencies']['pre']) < 0 ) {
    SELF['cron']['dependencies']['pre'][length(SELF['cron']['dependencies']['pre'])] = 'filecopy';
  };
  if ( is_defined(VOBOX_ENABLED_VOS_USER) ) {
    foreach (vo;user;VOBOX_ENABLED_VOS_USER) {
      contents = file_contents('personality/vobox/voname-box-proxyrenewal.template');
      variables = replace('(?m:THEVO)',vo,contents);
      variables = replace('(?m:THEADMIN)',user,contents);
      debug("contents = \n"+contents);
      script_name = vo+'-box-proxyrenewal';
      script_path = '/etc/init.d/'+script_name;
      # Add script
      SELF['filecopy']['services'][escape(script_path)] = nlist('config', contents,
                                                                'perms', '0755',<commit_msg>VOBOX: fix typo<commit_after>unique template personality/vobox/config;

# Proxy renewal interval (in hours) and log rotation parameters
variable VOBOX_PROXY_RENEWAL_INTERVAL ?= 6;
variable VOBOX_PROXY_RENEWAL_LOG_FREQUENCY ?= 'monthly';
variable VOBOX_PROXY_RENEWAL_LOG_ROTATION ?= 12;

# TCP parameters for optimal performances
variable VOBOX_TCP_MAX_BUFFER_SIZE ?= 8388608;
variable VOBOX_TCP_MAX_BACKLOG ?= 250000;

# List of directory to create in VO-specific directory.
# The following list is the minimum list: add it to site-specific defaults.
variable VOBOX_VO_DIRS_ROOT ?= EMI_LOCATION_VAR + '/lib/vobox';
variable VOBOX_VO_DIRECTORIES = {
  if ( !is_defined(SELF) || index('start',SELF) < 0 ) {
    SELF[length(SELF)] = 'start';
  };
  if ( index('stop',SELF) < 0 ) {
    SELF[length(SELF)] = 'stop';
  };
  if ( index('agents',SELF) < 0 ) {
    SELF[length(SELF)] = 'agents';
  };
  if ( index('info-provider',SELF) < 0 ) {
    SELF[length(SELF)] = 'info-provider';
  };
  if ( index('log',SELF) < 0 ) {
    SELF[length(SELF)] = 'log';
  };
  if ( index('proxy_repository',SELF) < 0 ) {
    SELF[length(SELF)] = 'proxy_repository';
  };
  SELF;
};


# Retrieve from VO_INFO the VO user enabled for access to VOBOX services.
# Normally there should be only one enabled VO, this has been checked before (personality/vobox/init)
variable VOBOX_ENABLED_VOS_USER ?= {
  foreach (i;vo;VOBOX_ENABLED_VOS) {
    if ( is_defined(VO_INFO[vo]['vobox_user']) ) {
      SELF[vo] = VO_INFO[vo]['vobox_user'];
    } else {
      debug('No FQAN allowed for VO '+vo+'. VOBOX services will not be configured for this vo');
    };
  };
  SELF;
};

# Create directories for each enable VOs
include { 'components/dirperm/config' };
'/software/components/dirperm/paths' = {
  if ( is_defined(VOBOX_ENABLED_VOS_USER) ) {
    foreach (vo;user;VOBOX_ENABLED_VOS_USER) {
      vo_dir_root = VOBOX_VO_DIRS_ROOT+'/'+vo;
      SELF[length(SELF)] = nlist('path', vo_dir_root,
                                 'perm', '0755',
                                 'owner', user,
                                 'type', 'd',
                                );
      foreach (i;dir;VOBOX_VO_DIRECTORIES) {
        SELF[length(SELF)] = nlist('path', vo_dir_root+'/'+dir,
                                   'perm', '0700',
                                   'owner', user,
                                   'type', 'd',
                                  );
      };
    };
  } else {
    debug('No FQAN allowed access to VOBOX services.');
  };
  SELF;
};


# Create proxy renewal script for each supported VO (normally only one)
# and configure related cron and logrotate.
# TODO: when filecopy will have been improved to support regexp-based
# editing of a source file already installed, this will be better to use
# the proxy renewal script installed by the RPM for easier
# synchronisation. But in lcg-vobox 1.0.4-4, the script is so buggy that
# it is unusable as is...

include { 'components/filecopy/config' };
include { 'components/chkconfig/config' };
include { 'components/cron/config' };
include { 'components/altlogrotate/config' };
'/software/components' = {
  if ( !is_defined(SELF['filecopy']['services']) ) {
    SELF['filecopy']['services'] = nlist();
  };
  if ( !is_defined(SELF['chkconfig']['service']) ) {
    SELF['chkconfig']['service'] = nlist();
  };
  if ( !is_defined(SELF['cron']['entries']) ) {
    SELF['cron']['entries'] = list();
  };
  if ( !is_defined(SELF['cron']['allow']) ) {
    SELF['cron']['allow'] = list();
  };
  if ( index('root',SELF['cron']['allow']) < 0 ) {
    SELF['cron']['allow'][length(SELF['cron']['allow'])] = 'root';
  };
  if ( !is_defined(SELF['altlogrotate']['entries']) ) {
    SELF['altlogrotate']['entries'] = nlist();
  };
  if ( index('filecopy',SELF['chkconfig']['dependencies']['pre']) < 0 ) {
    SELF['chkconfig']['dependencies']['pre'][length(SELF['chkconfig']['dependencies']['pre'])] = 'filecopy';
  };
  if ( index('filecopy',SELF['cron']['dependencies']['pre']) < 0 ) {
    SELF['cron']['dependencies']['pre'][length(SELF['cron']['dependencies']['pre'])] = 'filecopy';
  };
  if ( is_defined(VOBOX_ENABLED_VOS_USER) ) {
    foreach (vo;user;VOBOX_ENABLED_VOS_USER) {
      contents = file_contents('personality/vobox/voname-box-proxyrenewal.template');
      contents = replace('(?m:THEVO)',vo,contents);
      contents = replace('(?m:THEADMIN)',user,contents);
      debug("contents = \n"+contents);
      script_name = vo+'-box-proxyrenewal';
      script_path = '/etc/init.d/'+script_name;
      # Add script
      SELF['filecopy']['services'][escape(script_path)] = nlist('config', contents,
                                                                'perms', '0755',
{'fraction_non_alphanumeric': 0.16596060156746453, 'fraction_numerical': 0.0086846007201864, 'mean_word_length': 3.1987550022232103, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7459487', 'n_tokens_mistral': 3282, 'n_tokens_neox': 3162, 'n_words': 637}