<commit_before>#
# Cookbook Name:: oracle-omni
# Recipe:: createdb
#
# Copyright 2015, <NAME>
#
# All rights reserved - Do Not Redistribute
#

ob = node['oracle-omni']['rdbms']['oracle_base']
oh = node['oracle-omni']['rdbms']['oracle_home']
usr = node['oracle-omni']['rdbms']['user']
grp = node['oracle-omni']['rdbms']['groups'].keys.first
sid = node['oracle-omni']['rdbms']['sid']

pwd_content = Chef::EncryptedDataBagItem.load(
  node['oracle-omni']['oracle']['data_bag'],
  usr
)
rdbms_pwd = pwd_content['password']

pwd_content = Chef::EncryptedDataBagItem.load(
  node['oracle-omni']['oracle']['data_bag'],
  node['oracle-omni']['grid']['user']
)
asm_pwd = <PASSWORD>_content['password']

template "#{oh}/assistants/dbca/dbca.rsp" do
  source "#{node['oracle-omni']['rdbms']['version']}/dbca.rsp.erb"
  variables(
    rdbms_password: <PASSWORD>,
    asm_password: <PASSWORD>
  )
  sensitive true
  owner usr
  group grp
  mode '0775'
end

directory "#{ob}/cfgtoollogs" do
  mode '0775'
end

directory "#{ob}/admin" do
  mode '0770'
end

%w(listener sqlnet).each do |file|
  link "#{oh}/network/admin/#{file}.ora" do
    to "#{node['oracle-omni']['grid']['oracle_home']}/network/admin/#{file}.ora"
  end
end

execute 'create_db' do
  command "su -c 'export ORACLE_BASE=#{ob}; \
    export TNS_ADMIN=#{oh}/network/admin; #{oh}/bin/dbca -silent \
    -responseFile #{oh}/assistants/dbca/dbca.rsp' - #{usr}"
  not_if "#{oh}/bin/srvctl status database -d #{sid}", environment: {
    'ORACLE_HOME' => oh
  }
end<commit_msg>selinux hurdle clear<commit_after>#
# Cookbook Name:: oracle-omni
# Recipe:: createdb
#
# Copyright 2015, <NAME>
#
# All rights reserved - Do Not Redistribute
#

ob = node['oracle-omni']['rdbms']['oracle_base']
oh = node['oracle-omni']['rdbms']['oracle_home']
usr = node['oracle-omni']['rdbms']['user']
grp = node['oracle-omni']['rdbms']['groups'].keys.first
sid = node['oracle-omni']['rdbms']['sid']

pwd_content = Chef::EncryptedDataBagItem.load(
  node['oracle-omni']['oracle']['data_bag'],
  usr
)
rdbms_pwd = <PASSWORD>_content['password']

pwd_content = Chef::EncryptedDataBagItem.load(
  node['oracle-omni']['oracle']['data_bag'],
  node['oracle-omni']['grid']['user']
)
asm_pwd = <PASSWORD>_content['password']

template "#{oh}/assistants/dbca/dbca.rsp" do
  source "#{node['oracle-omni']['rdbms']['version']}/dbca.rsp.erb"
  variables(
    rdbms_password: <PASSWORD>,
    asm_password: <PASSWORD>
  )
  sensitive true
  owner usr
  group grp
  mode '0775'
end

directory "#{ob}/cfgtoollogs" do
  mode '0775'
end

directory "#{ob}/admin" do
  mode '0770'
end

%w(listener sqlnet).each do |file|
  link "#{oh}/network/admin/#{file}.ora" do
    to "#{node['oracle-omni']['grid']['oracle_home']}/network/admin/#{file}.ora"
  end
end

execute 'create_db' do
  command "setenforce 0; su -c 'export ORACLE_BASE=#{ob}; \
    export TNS_ADMIN=#{oh}/network/admin; #{oh}/bin/dbca -silent \
    -responseFile #{oh}/assistants/dbca/dbca.rsp' - #{usr}; \
    setenforce 1"
  not_if "#{oh}/bin/srvctl status database -d #{sid}", environment: {
    'ORACLE_HOME' => oh
  }
end
{'fraction_non_alphanumeric': 0.20536869340232858, 'fraction_numerical': 0.010996119016817595, 'mean_word_length': 5.076620825147348, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5244496', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1177, 'n_words': 213}