You are here

function fail2ban_update_7100 in Fail2ban Firewall Integration 7

Same name and namespace in other branches
  1. 7.2 fail2ban.install \fail2ban_update_7100()

Implementation of hook_update_N()

Migrate the module settings into a single array.

File

./fail2ban.install, line 18

Code

function fail2ban_update_7100() {

  // Create a new settings array.
  $settings = array(
    'logstring' => variable_get('fail2ban_logstring', 'Submitting address [!address] to the firewall'),
    'whitelist' => variable_get('fail2ban_whitelist', "127.0.0.0/8"),
    'logopt' => array(
      'identifier' => variable_get('fail2ban_identifier', 'drupal'),
      'options' => variable_get('fail2ban_options', array(
        LOG_ODELAY,
      )),
      'facility' => variable_get('fail2ban_facility', LOG_USER),
      'priority' => variable_get('fail2ban_priority', array(
        LOG_NOTICE,
      )),
    ),
  );

  // Save the new settings array.
  variable_set('fail2ban', $settings);

  // Remove the old settings.
  variable_del('fail2ban_identifier');
  variable_del('fail2ban_options');
  variable_del('fail2ban_facility');
  variable_del('fail2ban_priority');
  variable_del('fail2ban_logstring');
  variable_del('fail2ban_whitelist');

  // Tell the user what we did. Because it's nice.
  return t('Your fail2ban settings have been migrated to a new format.');
}