diff --git a/lib/tasks/site.rake b/lib/tasks/site.rake index 4782fe648..2ccf22498 100644 --- a/lib/tasks/site.rake +++ b/lib/tasks/site.rake @@ -23,6 +23,30 @@ namespace :site do end task :necessary_data => :environment do + auto_setting + site = Site.first + site.title = 'RulingOrbit Demo Site' + site.resque_namespace = @resque_namespace + + # home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') + design = Design.first + site = Site.first + site.design = design + site.save + theme = design.themes.first + home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id ) + + home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"} + home.save + + puts "Rember to restart server after you setup all sites for starting God" + end + + task :start_auto_setting => :environment do + auto_setting + end + + def auto_setting puts "Enter your resque namespace[Orbit]:......" @resque_namespace = STDIN.gets.gsub("\n",'') @resque_namespace = APP_CONFIG['orbit'] if @resque_namespace.empty? @@ -50,42 +74,25 @@ namespace :site do File.open("config/solr.god", 'w') { |file| file.write(solr_setting.result) } create_rulingcom_logrotate end - - site = Site.first - site.title = 'RulingOrbit Demo Site' - site.resque_namespace = @resque_namespace - site.save - - # home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') - design = Design.first - site = Site.first - site.design = design - site.save - theme = design.themes.first - home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id ) - - home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"} - home.save - - puts "Rember to restart server after you setup all sites for starting God" - - def create_rulingcom_logrotate - @project_folder = ENV["PWD"] - puts "Is your Orbit folder: #{@project_folder} (If YES => Press enter,or enter your path)" - user_enter_project_folder = STDIN.gets.gsub("\n",'') - @project_folder = user_enter_project_folder unless user_enter_project_folder.empty? - - @user_home_folder = ENV["HOME"] - puts "Is your Home folder: #{@user_home_folder} (If YES => Press enter,or enter your path)" - user_enter_home_folder = STDIN.gets.gsub("\n",'') - @user_home_folder = user_enter_home_folder unless user_enter_home_folder.empty? - - logrotate_setting = ERB.new(File.new("lib/template/setting/rulingcom_log.erb").read) - File.open("#{@project_loc}/tmp/logrotate_setting", 'w') { |file| file.write(logrotate_setting.result) } - - `sudo cp #{@project_loc}/tmp/logrotate_setting /etc/logrotate.d/rulingcom` - end - end + +def create_rulingcom_logrotate + `sudo mkdir -p /var/log/rulingcom` unless File.directory? "/var/log/rulingcom" + @project_folder = ENV["PWD"] + puts "Is your Orbit folder: #{@project_folder} (If YES => Press enter,or enter your path)" + user_enter_project_folder = STDIN.gets.gsub("\n",'') + @project_folder = user_enter_project_folder unless user_enter_project_folder.empty? + + @user_home_folder = ENV["HOME"] + puts "Is your Home folder: #{@user_home_folder} (If YES => Press enter,or enter your path)" + user_enter_home_folder = STDIN.gets.gsub("\n",'') + @user_home_folder = user_enter_home_folder unless user_enter_home_folder.empty? + + logrotate_setting = ERB.new(File.new("lib/template/setting/rulingcom_log.erb").read) + File.open("#{@project_loc}/tmp/logrotate_setting", 'w') { |file| file.write(logrotate_setting.result) } + + `sudo cp #{@project_loc}/tmp/logrotate_setting /etc/logrotate.d/rulingcom` +end + end