cloud change
This commit is contained in:
@@ -25,8 +25,7 @@ class ApplicationController < ActionController::Base
|
|||||||
def lookup_domain
|
def lookup_domain
|
||||||
|
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
if request.subdomain.present? && request.subdomain != "www"
|
||||||
from = request.subdomain.downcase #+ "." + request.domain.downcase
|
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||||
puts from
|
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||||
if (!@license.nil?)
|
if (!@license.nil?)
|
||||||
# logger.info "Location - " + @license.name
|
# logger.info "Location - " + @license.name
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class InstallController < BaseController
|
|||||||
db_schema = params[:db_schema]
|
db_schema = params[:db_schema]
|
||||||
db_user = params[:db_user]
|
db_user = params[:db_user]
|
||||||
db_password = params[:db_password]
|
db_password = params[:db_password]
|
||||||
phrase = key_base == "<%= ENV['secret_key_base'] %>"? license_key : "<%= ENV['secret_key_base'] %>"
|
phrase = license_key
|
||||||
|
|
||||||
# Check Exists IV
|
# Check Exists IV
|
||||||
if flag == "<%= ENV['AES_IV'] %>"
|
if flag == "<%= ENV['AES_IV'] %>"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class License
|
|||||||
if cache_license.nil?
|
if cache_license.nil?
|
||||||
##change the d/e key
|
##change the d/e key
|
||||||
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
||||||
@params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} }
|
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: iv} }
|
||||||
response = self.class.get("/subdomain", @params)
|
response = self.class.get("/subdomain", @params)
|
||||||
@license = response.parsed_response
|
@license = response.parsed_response
|
||||||
|
|
||||||
@@ -83,18 +83,17 @@ class License
|
|||||||
|
|
||||||
# License Activation
|
# License Activation
|
||||||
def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password)
|
def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password)
|
||||||
@params = { query: { lookup_type: self.server_mode, encrypted_key: key, iv_key: iv, license_key: license_key } }
|
@params = { query: { lookup_type: self.server_mode, iv_key: iv, license_key: license_key } }
|
||||||
response = self.class.get("/activate", @params)
|
response = self.class.get("/activate", @params)
|
||||||
@activate = response.parsed_response
|
@activate = response.parsed_response
|
||||||
|
|
||||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
||||||
|
|
||||||
if (@activate["status"])
|
if (@activate["status"])
|
||||||
response = create_license_file(@activate)
|
response = create_license_file(@activate)
|
||||||
if(response["status"])
|
if(response[:status])
|
||||||
sym_path = "/home/yan/symmetric/"
|
sym_path = "/home/yan/symmetric/"
|
||||||
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
|
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
|
||||||
if(response["status"])
|
if(response[:status])
|
||||||
response = run_symmetric(sym_path)
|
response = run_symmetric(sym_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -141,7 +140,7 @@ class License
|
|||||||
if File.exist?("config/license.yml")
|
if File.exist?("config/license.yml")
|
||||||
File.open("config/license.yml").each do |line|
|
File.open("config/license.yml").each do |line|
|
||||||
if line.include? (key)
|
if line.include? (key)
|
||||||
decrypted_line_array = line.split(":")
|
decrypted_line_array = line.split(": ")
|
||||||
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE'])
|
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -162,20 +161,20 @@ class License
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
# Licese File Creation
|
# Licese File Creation
|
||||||
f = File.open("config/license.yml", "w")
|
File.open("config/license.yml", "w") do |f|
|
||||||
f.write("iv_key: #{response_data['iv_key']}\n")
|
f.puts("iv_key: #{response_data['iv_key']}")
|
||||||
f.write("shop_name: #{response_data['shop_name']}\n")
|
f.puts("shop_name: #{response_data['shop_name']}")
|
||||||
f.write("email: #{response_data['email']}\n")
|
f.puts("email: #{response_data['email']}")
|
||||||
f.write("telephone: #{response_data['telephone']}\n")
|
f.puts("telephone: #{response_data['telephone']}")
|
||||||
f.write("fax: #{response_data['fax']}\n")
|
f.puts("fax: #{response_data['fax']}")
|
||||||
f.write("address: #{response_data['address']}\n")
|
f.puts("address: #{response_data['address']}")
|
||||||
f.write("dbhost: #{response_data['dbhost']}\n")
|
f.puts("dbhost: #{response_data['dbhost']}")
|
||||||
f.write("dbschema: #{response_data['dbschema']}\n")
|
f.puts("dbschema: #{response_data['dbschema']}")
|
||||||
f.write("dbusername: #{response_data['dbusername']}\n")
|
f.puts("dbusername: #{response_data['dbusername']}")
|
||||||
f.write("dbpassword: #{response_data['dbpassword']}\n")
|
f.puts("dbpassword: #{response_data['dbpassword']}")
|
||||||
f.write("api_token: #{response_data['api_token']}\n")
|
f.puts("api_token: #{response_data['api_token']}")
|
||||||
f.write("app_token: #{response_data['app_token']}\n")
|
f.puts("app_token: #{response_data['app_token']}")
|
||||||
f.close
|
end
|
||||||
rescue IOError
|
rescue IOError
|
||||||
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||||
end
|
end
|
||||||
@@ -237,18 +236,19 @@ class License
|
|||||||
|
|
||||||
# Run Symmetric
|
# Run Symmetric
|
||||||
def run_symmetric(sym_path)
|
def run_symmetric(sym_path)
|
||||||
check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
||||||
check_sym_proc_str = check_sym_proc_str.split("\n")
|
# check_sym_proc_str = check_sym_proc_str.split("\n")
|
||||||
sym_install_status = check_sym_proc_str[0].split(": ")
|
# sym_install_status = check_sym_proc_str[0].split(": ")
|
||||||
# sym_run_status = check_sym_proc_str[1].split(": ")
|
|
||||||
|
check_sym_proc_str = `#{"service SymmetricDS status"}`
|
||||||
|
|
||||||
# Check Sym Installed
|
# Check Sym Installed
|
||||||
if sym_install_status[1] == "false"
|
# if sym_install_status[1] == "false"
|
||||||
response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
||||||
end
|
# end
|
||||||
|
|
||||||
# Run Sym Service
|
# Run Sym Service
|
||||||
sym_run_status = check_sym_running(check_sym_proc_str[1], sym_path)
|
sym_run_status = check_sym_running(check_sym_proc_str, sym_path)
|
||||||
if sym_run_status
|
if sym_run_status
|
||||||
# Create Sym Table
|
# Create Sym Table
|
||||||
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
|
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
|
||||||
@@ -272,18 +272,23 @@ class License
|
|||||||
# Check Symmetric Running
|
# Check Symmetric Running
|
||||||
def check_sym_running(status, sym_path)
|
def check_sym_running(status, sym_path)
|
||||||
# Run Sym Service
|
# Run Sym Service
|
||||||
if status.include? "Server is already running"
|
# if status.include? "Server is already running"
|
||||||
return true
|
# return true
|
||||||
elsif status.include? "false"
|
# elsif status.include? "false"
|
||||||
sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
||||||
if sym_start_str.include? "Started"
|
# if sym_start_str.include? "Started"
|
||||||
return true
|
# return true
|
||||||
else
|
# else
|
||||||
check_sym_running(sym_start_status[0])
|
# check_sym_running(sym_start_status[0])
|
||||||
end
|
# end
|
||||||
else
|
# else
|
||||||
|
# return true
|
||||||
|
# end
|
||||||
|
|
||||||
|
if status.include? "Active: active (running)" #"Server is already running"
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete License File
|
# Delete License File
|
||||||
|
|||||||
@@ -13,10 +13,13 @@ class MyAesCrypt
|
|||||||
# for cloud is lookup
|
# for cloud is lookup
|
||||||
# for local is license_key
|
# for local is license_key
|
||||||
# iv_salt = passphrase+"c2l"
|
# iv_salt = passphrase+"c2l"
|
||||||
|
passphrase = passphrase + ENV['SX_KEY']
|
||||||
|
passphrase = passphrase.gsub(".","_")
|
||||||
digest = Digest::SHA256.new
|
digest = Digest::SHA256.new
|
||||||
key_digest = digest.update(passphrase)
|
key_digest = digest.update(passphrase)
|
||||||
# iv_digest = digest.update(iv_salt)
|
# iv_digest = digest.update(iv_salt)
|
||||||
key = key_digest.digest
|
key = key_digest.digest
|
||||||
|
|
||||||
# iv = iv_digest.digest
|
# iv = iv_digest.digest
|
||||||
ENV['AES_KEY'] = cipher_key = Base64.encode64(key) # stores the key in key, and also sets the generated key on the @cipher
|
ENV['AES_KEY'] = cipher_key = Base64.encode64(key) # stores the key in key, and also sets the generated key on the @cipher
|
||||||
ENV['AES_IV'] = cipher_iv = Base64.encode64(@cipher.random_iv) # stores the iv in iv, and also sets the generated iv on the @cipher
|
ENV['AES_IV'] = cipher_iv = Base64.encode64(@cipher.random_iv) # stores the iv in iv, and also sets the generated iv on the @cipher
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
iv_key: vO8MJlASMmPRf6Ivw3QK+A==
|
|
||||||
|
|
||||||
shop_name: bitp
|
|
||||||
email: yanaung.nyein@code2lab.com
|
|
||||||
telephone: 111111
|
|
||||||
fax: 111111
|
|
||||||
address: bitp
|
|
||||||
dbhost: vd52jkRoCOPpHX0tsYp1HQ==
|
|
||||||
|
|
||||||
dbschema: 7L5CvrQvsspSYgx5Ng3tDg==
|
|
||||||
|
|
||||||
dbusername: G0QLCPnSiRmGQ7ekVWy5wA==
|
|
||||||
|
|
||||||
dbpassword: ahQVj/eThBKnwpv1tcvNGA==
|
|
||||||
|
|
||||||
api_token:
|
|
||||||
app_token:
|
|
||||||
@@ -13,8 +13,9 @@
|
|||||||
development:
|
development:
|
||||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||||
sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api
|
sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api
|
||||||
server_mode: application
|
server_mode: cloud
|
||||||
cipher_type: AES-256-CBC
|
cipher_type: AES-256-CBC
|
||||||
|
sx_key: Wh@t1$C2L
|
||||||
aes_key: <%= ENV['AES_KEY'] %>
|
aes_key: <%= ENV['AES_KEY'] %>
|
||||||
aes_iv: <%= ENV['AES_IV'] %>
|
aes_iv: <%= ENV['AES_IV'] %>
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ production:
|
|||||||
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
||||||
sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002
|
sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002
|
||||||
server_mode: cloud
|
server_mode: cloud
|
||||||
|
sx_key: Wh@t1$C2L
|
||||||
aes_key: <%= ENV['AES_KEY'] %>
|
aes_key: <%= ENV['AES_KEY'] %>
|
||||||
aes_iv: <%= ENV['AES_IV'] %>
|
aes_iv: <%= ENV['AES_IV'] %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user