diff --git a/app/controllers/sym_control_controller.rb b/app/controllers/sym_control_controller.rb new file mode 100644 index 00000000..816b8f2c --- /dev/null +++ b/app/controllers/sym_control_controller.rb @@ -0,0 +1,35 @@ +class SymControlController < BaseController + skip_before_action :verify_authenticity_token + + 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 => "

Success!

" + end + else + render :text => "

Sym Sql file not found!

" + end + end + else + render :text => "

Sym not running!

" + end + end + +end \ No newline at end of file diff --git a/app/views/sym_control/run.html.erb b/app/views/sym_control/run.html.erb new file mode 100755 index 00000000..8b137891 --- /dev/null +++ b/app/views/sym_control/run.html.erb @@ -0,0 +1 @@ +