Last active
January 17, 2017 12:18
-
-
Save michelemina/8649633 to your computer and use it in GitHub Desktop.
oracle client capistrano install task: useful when ruby-oci8 is required in a server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
set :default_environment, { | |
'LD_LIBRARY_PATH' => "#{shared_dir}/oracle/" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remote_file_exists?(full_path) | |
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip | |
end | |
namespace :oracle do | |
task :install do | |
instant_client = "instantclient-basic-linux.x64-12.1.0.1.0.zip" | |
instant_client_sdk = "instantclient-sdk-linux.x64-12.1.0.1.0.zip" | |
oracle_path = "#{shared_path}/oracle/" | |
instant_client_path = "#{oracle_path}instantclient_12_1" | |
run "#{sudo} apt-get -y update" | |
run "#{sudo} apt-get -y install libaio1 unzip" | |
run "mkdir -p #{oracle_path}" | |
unless remote_file_exists?(instant_client_path) | |
upload File.expand_path("../templates/oracle/#{instant_client}", __FILE__), "#{oracle_path}#{instant_client}" | |
upload File.expand_path("../templates/oracle/#{instant_client_sdk}", __FILE__), "#{oracle_path}#{instant_client_sdk}" | |
run "cd #{oracle_path}; unzip #{instant_client_sdk}" | |
run "cd #{oracle_path}; unzip #{instant_client}" | |
run "cd #{instant_client_path}; ln -s libclntsh.so.12.1 libclntsh.so" | |
put "#{instant_client_path}", "/tmp/oracle.conf" | |
run "#{sudo} mv /tmp/oracle.conf /etc/ld.so.conf.d/oracle.conf" | |
run "sudo ldconfig" | |
end | |
end | |
after "deploy:install", "oracle:install" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment