Files
sx-fc/app/controllers/sym_control_controller.rb
2018-01-12 15:07:11 +06:30

46 lines
1.6 KiB
Ruby

class SymControlController < BaseController
skip_before_action :verify_authenticity_token
http_basic_authenticate_with name: "vip", password: "!abcABC01"
def run
sym_path = "/home/yan/symmetric/"
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 check_sym_proc_str.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
# Create Sym Table
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym
render :text => "<h1>Success!</h1>"
end
else
render :text => "<h1>Sym Sql file not found!</h1>"
end
end
else
render :text => "<h1>Sym not running!</h1>"
end
end
def get_key
license = License.new(ENV["SX_PROVISION_URL"])
status = license.get_key
if status
render :text => "<h1>Success!</h1>"
else
render :text => "<h1>Not Get!</h1>"
end
end
end