cloud change
This commit is contained in:
@@ -25,8 +25,7 @@ class ApplicationController < ActionController::Base
|
||||
def lookup_domain
|
||||
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
from = request.subdomain.downcase #+ "." + request.domain.downcase
|
||||
puts from
|
||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.name
|
||||
|
||||
@@ -17,7 +17,7 @@ class InstallController < BaseController
|
||||
db_schema = params[:db_schema]
|
||||
db_user = params[:db_user]
|
||||
db_password = params[:db_password]
|
||||
phrase = key_base == "<%= ENV['secret_key_base'] %>"? license_key : "<%= ENV['secret_key_base'] %>"
|
||||
phrase = license_key
|
||||
|
||||
# Check Exists IV
|
||||
if flag == "<%= ENV['AES_IV'] %>"
|
||||
|
||||
@@ -43,7 +43,7 @@ class License
|
||||
if cache_license.nil?
|
||||
##change the d/e 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)
|
||||
@license = response.parsed_response
|
||||
|
||||
@@ -83,18 +83,17 @@ class License
|
||||
|
||||
# License Activation
|
||||
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)
|
||||
@activate = response.parsed_response
|
||||
|
||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
||||
|
||||
if (@activate["status"])
|
||||
response = create_license_file(@activate)
|
||||
if(response["status"])
|
||||
if(response[:status])
|
||||
sym_path = "/home/yan/symmetric/"
|
||||
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)
|
||||
end
|
||||
end
|
||||
@@ -136,12 +135,12 @@ class License
|
||||
end
|
||||
|
||||
# read line by key for license file
|
||||
def read_license(key)
|
||||
def read_license(key)
|
||||
decrypted_line = ""
|
||||
if File.exist?("config/license.yml")
|
||||
File.open("config/license.yml").each do |line|
|
||||
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'])
|
||||
end
|
||||
end
|
||||
@@ -162,20 +161,20 @@ class License
|
||||
|
||||
begin
|
||||
# Licese File Creation
|
||||
f = File.open("config/license.yml", "w")
|
||||
f.write("iv_key: #{response_data['iv_key']}\n")
|
||||
f.write("shop_name: #{response_data['shop_name']}\n")
|
||||
f.write("email: #{response_data['email']}\n")
|
||||
f.write("telephone: #{response_data['telephone']}\n")
|
||||
f.write("fax: #{response_data['fax']}\n")
|
||||
f.write("address: #{response_data['address']}\n")
|
||||
f.write("dbhost: #{response_data['dbhost']}\n")
|
||||
f.write("dbschema: #{response_data['dbschema']}\n")
|
||||
f.write("dbusername: #{response_data['dbusername']}\n")
|
||||
f.write("dbpassword: #{response_data['dbpassword']}\n")
|
||||
f.write("api_token: #{response_data['api_token']}\n")
|
||||
f.write("app_token: #{response_data['app_token']}\n")
|
||||
f.close
|
||||
File.open("config/license.yml", "w") do |f|
|
||||
f.puts("iv_key: #{response_data['iv_key']}")
|
||||
f.puts("shop_name: #{response_data['shop_name']}")
|
||||
f.puts("email: #{response_data['email']}")
|
||||
f.puts("telephone: #{response_data['telephone']}")
|
||||
f.puts("fax: #{response_data['fax']}")
|
||||
f.puts("address: #{response_data['address']}")
|
||||
f.puts("dbhost: #{response_data['dbhost']}")
|
||||
f.puts("dbschema: #{response_data['dbschema']}")
|
||||
f.puts("dbusername: #{response_data['dbusername']}")
|
||||
f.puts("dbpassword: #{response_data['dbpassword']}")
|
||||
f.puts("api_token: #{response_data['api_token']}")
|
||||
f.puts("app_token: #{response_data['app_token']}")
|
||||
end
|
||||
rescue IOError
|
||||
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||
end
|
||||
@@ -237,18 +236,19 @@ class License
|
||||
|
||||
# Run Symmetric
|
||||
def run_symmetric(sym_path)
|
||||
check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
||||
check_sym_proc_str = check_sym_proc_str.split("\n")
|
||||
sym_install_status = check_sym_proc_str[0].split(": ")
|
||||
# sym_run_status = check_sym_proc_str[1].split(": ")
|
||||
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
||||
# check_sym_proc_str = check_sym_proc_str.split("\n")
|
||||
# sym_install_status = check_sym_proc_str[0].split(": ")
|
||||
|
||||
check_sym_proc_str = `#{"service SymmetricDS status"}`
|
||||
|
||||
# Check Sym Installed
|
||||
if sym_install_status[1] == "false"
|
||||
response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
||||
end
|
||||
# if sym_install_status[1] == "false"
|
||||
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
||||
# end
|
||||
|
||||
# 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
|
||||
# Create Sym Table
|
||||
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
|
||||
@@ -272,18 +272,23 @@ class License
|
||||
# Check Symmetric Running
|
||||
def check_sym_running(status, sym_path)
|
||||
# Run Sym Service
|
||||
if status.include? "Server is already running"
|
||||
# if status.include? "Server is already running"
|
||||
# return true
|
||||
# elsif status.include? "false"
|
||||
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
||||
# if sym_start_str.include? "Started"
|
||||
# return true
|
||||
# else
|
||||
# check_sym_running(sym_start_status[0])
|
||||
# end
|
||||
# else
|
||||
# return true
|
||||
# end
|
||||
|
||||
if status.include? "Active: active (running)" #"Server is already running"
|
||||
return true
|
||||
elsif status.include? "false"
|
||||
sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
||||
if sym_start_str.include? "Started"
|
||||
return true
|
||||
else
|
||||
check_sym_running(sym_start_status[0])
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Delete License File
|
||||
@@ -318,7 +323,7 @@ class License
|
||||
|
||||
key = Base64.decode64(ENV['AES_KEY'])
|
||||
iv = Base64.decode64(ENV['AES_IV'])
|
||||
|
||||
|
||||
if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
|
||||
host = Base64.decode64(@license["dbhost"])
|
||||
dbschema = Base64.decode64(@license["dbschema"])
|
||||
|
||||
@@ -13,10 +13,13 @@ class MyAesCrypt
|
||||
# for cloud is lookup
|
||||
# for local is license_key
|
||||
# iv_salt = passphrase+"c2l"
|
||||
passphrase = passphrase + ENV['SX_KEY']
|
||||
passphrase = passphrase.gsub(".","_")
|
||||
digest = Digest::SHA256.new
|
||||
key_digest = digest.update(passphrase)
|
||||
# iv_digest = digest.update(iv_salt)
|
||||
key = key_digest.digest
|
||||
key = key_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_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:
|
||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||
sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api
|
||||
server_mode: application
|
||||
server_mode: cloud
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
aes_key: <%= ENV['AES_KEY'] %>
|
||||
aes_iv: <%= ENV['AES_IV'] %>
|
||||
|
||||
@@ -27,6 +28,7 @@ production:
|
||||
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
||||
sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002
|
||||
server_mode: cloud
|
||||
sx_key: Wh@t1$C2L
|
||||
aes_key: <%= ENV['AES_KEY'] %>
|
||||
aes_iv: <%= ENV['AES_IV'] %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user