diff --git a/app/controllers/admin/site_panel_controller.rb b/app/controllers/admin/site_panel_controller.rb index 3351211..861d66c 100644 --- a/app/controllers/admin/site_panel_controller.rb +++ b/app/controllers/admin/site_panel_controller.rb @@ -70,9 +70,9 @@ class Admin::SitePanelController < OrbitAdminController site_construct.user_id = current_user.id.to_s site_construct.status = "creating" site_construct.save - git_user = "chiu" - git_password = "orbit_is_great_1" - git_url = "http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git" + git_url = "http://ruling.digital/git"#"http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git" + git_template_url = "http://gitlab.tp.rulingcom.com/themes/default-theme.git" + git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git" site_server = SiteServer.where(:server_name=>site_construct.server_type).first ip = site_server.ip user = site_server.account @@ -84,16 +84,16 @@ class Admin::SitePanelController < OrbitAdminController path = site_construct.path site_construct_id = site_construct.id.to_s Thread.new do - system("rake create_site:create_site[#{git_user},#{git_password},#{git_url},#{ip},#{user},#{password},#{site_name},#{domain_name},#{port},#{db_name},#{path},#{site_construct_id}]") + system("rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']") end redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}" end def create_site site_construct = SiteConstruct.find(params[:id]) site_construct.user_id = current_user.id.to_s - git_user = "chiu" - git_password = "orbit_is_great_1" - git_url = "http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git" + git_url = "http://ruling.digital/git"#"http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git" + git_template_url = "http://gitlab.tp.rulingcom.com/themes/default-theme.git" + git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git" site_server = SiteServer.where(:server_name=>site_construct.server_type).first ip = site_server.ip user = site_server.account @@ -105,7 +105,7 @@ class Admin::SitePanelController < OrbitAdminController path = site_construct.path site_construct_id = params[:id] Thread.new do - system("rake create_site:create_site['#{git_user}','#{git_password}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']") + system("rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']") end render :json =>{"success"=>true} end diff --git a/app/views/admin/site_panel/_form.html.erb b/app/views/admin/site_panel/_form.html.erb index 2db14f3..49078f8 100644 --- a/app/views/admin/site_panel/_form.html.erb +++ b/app/views/admin/site_panel/_form.html.erb @@ -161,6 +161,7 @@ }) $("#site_construct_site_type").val("School"); $("form.main-forms").submit(function(){ + $("#domain_name").removeAttr('disabled'); $("#path").removeAttr("disabled"); var type = $("#site_construct_site_type").val(); type = (type == "School" ? "school_sites" : "orbit_sites" ); diff --git a/lib/tasks/create_site.rake b/lib/tasks/create_site.rake index 72a7c78..23c4dda 100644 --- a/lib/tasks/create_site.rake +++ b/lib/tasks/create_site.rake @@ -2,7 +2,7 @@ require 'net/ssh' require 'pathname' namespace :create_site do desc "Create Site Script" - task :create_site,[:git_user,:git_password,:git_url,:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args| + task :create_site,[:git_template_url,:git_extension_url,:git_url,:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args| @password = args.password puts args if args.site_construct_id.blank? @@ -62,7 +62,10 @@ namespace :create_site do dir = dir.dirname end update_infos("cloning orbit4-5 from #{args.git_url} to #{args.path}/#{args.site_name}") - exec_ssh_command_by_sudo_for_create(ssh,"git clone #{args.git_url.gsub("http://","http://#{args.git_user+':'+args.git_password+'@'}").gsub("https://","https://#{args.git_user+':'+args.git_password+'@'}")} #{args.path}/#{args.site_name}") + exec_ssh_command_by_sudo_for_create(ssh,"git clone #{args.git_url} #{args.path}/#{args.site_name}") + exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name} && git submodule add #{args.git_template_url} app/templates/default-theme'") + exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name} && git submodule add #{args.git_extension_url} modules'") + ssh.exec!("bash -l -c 'cd #{args.path}/#{args.site_name} && ln -s modules/* .'") exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R") exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R") db_setting_text = ssh.exec!("cat #{args.path}/#{args.site_name}/config/mongoid.yml") @@ -82,11 +85,11 @@ namespace :create_site do else bundle_dir = gemdir.gsub("\n","") + '/bin/bundle' update_infos("execing bundle install...") - exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\n#{bundle_dir} install'",true) - exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\n#{bundle_dir} install'") + exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nbundle install'",true) + exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nbundle install'") update_infos("finish execing bundle install") update_infos("starting #{args.site_name} web server to development") - outputs = exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nkill -s TERM `fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\n#{bundle_dir} exec unicorn_rails -c config/unicorn.rb -D -E development\n'") + outputs = exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nkill -s TERM `fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\nbundle exec unicorn_rails -c config/unicorn.rb -D -E development\n'") if outputs.include? "not writable" exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R") exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R")