From 15602d52b598caecbb1daabe621e1d2e02df6be7 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 25 Mar 2013 17:09:59 +0100 Subject: add ionice for backup jobs --- lib/tasks/backup.rake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index 83bcfd3..0dbadad 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -25,32 +25,32 @@ namespace :backup do tmp_dir = "/tmp/gs5_restore_directory" FileUtils.rm_rf tmp_dir FileUtils.mkdir_p tmp_dir - system "cd #{tmp_dir} && nice -n 19 sudo /bin/tar xzf #{restore_job.backup_file.path}" + system "cd #{tmp_dir} && nice -n 19 ionice -c2 -n7 sudo /bin/tar xzf #{restore_job.backup_file.path}" restore_directory = Dir.glob("/tmp/gs5_restore_directory/*").first - system "cd #{restore_directory} && nice -n 19 sudo /bin/tar xf GS5.tar && rm GS5.tar" + system "cd #{restore_directory} && nice -n 19 ionice -c2 -n7 sudo /bin/tar xf GS5.tar && rm GS5.tar" # Restore faxes # if File.exists?("#{restore_directory}/GS5/archives/faxes.tar.gz") - system "cd / && nice -n 19 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/faxes.tar.gz" + system "cd / && nice -n 19 ionice -c2 -n7 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/faxes.tar.gz" end # Restore voicemails # if File.exists?("#{restore_directory}/GS5/archives/voicemails.tar.gz") - system "cd / && nice -n 19 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/voicemails.tar.gz" + system "cd / && nice -n 19 ionice -c2 -n7 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/voicemails.tar.gz" end # Restore recordings # if File.exists?("#{restore_directory}/GS5/archives/recordings.tar.gz") - system "cd / && nice -n 19 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/recordings.tar.gz" + system "cd / && nice -n 19 ionice -c2 -n7 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/recordings.tar.gz" end # Restore avatars # if File.exists?("#{restore_directory}/GS5/archives/avatars.tar.gz") - system "cd / && nice -n 19 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/avatars.tar.gz" + system "cd / && nice -n 19 ionice -c2 -n7 sudo /bin/tar xzfP #{restore_directory}/GS5/archives/avatars.tar.gz" end # Delete the archive tar.gz to get more air to breathe @@ -65,11 +65,11 @@ namespace :backup do db_user = system_odbc_configuration['gemeinschaft']['USER'] db_password = system_odbc_configuration['gemeinschaft']['PASSWORD'] - system "nice -n 19 gunzip < #{restore_directory}/GS5/databases/MySQL/gemeinschaft.sql.gz | nice -n 19 mysql -u #{db_user} -p#{db_password} #{database}" + system "nice -n 19 ionice -c2 -n7 gunzip < #{restore_directory}/GS5/databases/MySQL/gemeinschaft.sql.gz | nice -n 19 ionice -c2 -n7 mysql -u #{db_user} -p#{db_password} #{database}" FileUtils.rm_rf tmp_dir - system "cd /opt/gemeinschaft && nice -n 19 rake db:migrate" + system "cd /opt/gemeinschaft && nice -n 19 ionice -c2 -n7 rake db:migrate" # Rebuild the thumbnails # -- cgit v1.2.3 From deae02d7ae971da152da39193c89ee2b85d6207e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 2 Apr 2013 12:17:32 +0200 Subject: create voicemail_accounts --- lib/tasks/csv_user_import.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/tasks/csv_user_import.rake b/lib/tasks/csv_user_import.rake index 81959d5..e65bc1f 100644 --- a/lib/tasks/csv_user_import.rake +++ b/lib/tasks/csv_user_import.rake @@ -129,6 +129,16 @@ namespace :user_import do end if user + # Create voicemail account + voicemail_account = user.voicemail_accounts.first + if !voicemail_account + if VoicemailAccount.where(:name => "user_#{user.user_name}").count == 0 + voicemail_account = user.voicemail_accounts.create(:name => "user_#{user.user_name}", :active => true ) + else + voicemail_account = user.voicemail_accounts.create(:active => true) + end + end + # Find or create a sip_accounts ['VoipNr1', 'VoipNr2', 'VoipNr3'].each_with_index do |phone_number_type, index| @@ -141,6 +151,9 @@ namespace :user_import do if !phone_number_type.blank? && !csv_user[phone_number_type].blank? sip_account = user.sip_accounts.where(:auth_name => auth_name).first if sip_account + if sip_account.voicemail_account != voicemail_account + sip_account.update_attributes(:voicemail_account_id => voicemail_account.id) + end if sip_account.caller_name.to_s != user.to_s sip_account.update_attributes(:caller_name => user.to_s) end @@ -154,6 +167,7 @@ namespace :user_import do :hotdeskable => true, :callforward_rules_act_per_sip_account => true, :gs_node_id => gs_node_id, + :voicemail_account_id => voicemail_account.id, ) end -- cgit v1.2.3 From f70038715ec1ae40fac7177f4ea44e2f9dd5140b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 4 May 2013 08:57:02 +0200 Subject: area_codes_update:nanp rake task added --- lib/tasks/update_area_codes.rake | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/tasks/update_area_codes.rake (limited to 'lib') diff --git a/lib/tasks/update_area_codes.rake b/lib/tasks/update_area_codes.rake new file mode 100644 index 0000000..0d6eadd --- /dev/null +++ b/lib/tasks/update_area_codes.rake @@ -0,0 +1,52 @@ +namespace :area_codes_update do + desc "Update Area Codes and Central Office Codes." + task :nanp => :environment do + ARCHIVE_URL = 'http://www.nanpa.com/nanp1/allutlzd.zip' + ARCHIVE_PATH = '/tmp/nanp_area_codes.zip' + SOURCE_FILE = '/tmp/allutlzd.txt' + + country = Country.where(:name => "United States of America" ).first + + require 'open-uri' + open(ARCHIVE_PATH, 'wb') do |file| + puts 'Downloading area codes list...' + file << open(ARCHIVE_URL).read + end + + system("cd /tmp/ && unzip #{ARCHIVE_PATH}") + all_lines_count = 0 + File.open(SOURCE_FILE, 'r') {|file| all_lines_count = file.read.count("\n")} + + lines = 0 + File.open(SOURCE_FILE, 'r').each_line do |line| + lines += 1 + + if lines == 1 + next + end + + line_array = line.split("\t") + + state = line_array[0].strip + npa, ncc = line_array[1].split("-") + rate_center = line_array[4].strip.titleize + + if rate_center.blank? || line_array[6].strip != 'AS' || rate_center == 'Xxxxxxxxxx' + next + end + + name = "#{rate_center}, #{state}" + percent = lines.to_f / all_lines_count.to_f * 100.0 + puts "#{all_lines_count} / #{lines} / #{percent.to_i}% / Processing #{name} / +1-#{npa}-#{ncc} " + + area_code = AreaCode.where(:country_id => country.id, :area_code => npa, :central_office_code => ncc).first + if !area_code + area_code = AreaCode.create(:country_id => country.id, :area_code => npa, :central_office_code => ncc, :name => name) + else + if area_code.name != name + area_code.update_attributes({ :name => name }) + end + end + end + end +end \ No newline at end of file -- cgit v1.2.3 From e6885147f4ca9c4c56ae4542196b93a2db995898 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 31 May 2013 14:34:14 +0200 Subject: update geo_ip countries rake task added --- lib/tasks/update_geo_ip_countries.rake | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/tasks/update_geo_ip_countries.rake (limited to 'lib') diff --git a/lib/tasks/update_geo_ip_countries.rake b/lib/tasks/update_geo_ip_countries.rake new file mode 100644 index 0000000..86b98fe --- /dev/null +++ b/lib/tasks/update_geo_ip_countries.rake @@ -0,0 +1,44 @@ +namespace :geo_ip_update do + desc "Update Area Codes and Central Office Codes." + task :country => :environment do + ARCHIVE_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip' + ARCHIVE_PATH = '/tmp/geo_ip_countries.zip' + SOURCE_FILE = '/tmp/GeoIPCountryWhois.csv' + + require 'open-uri' + open(ARCHIVE_PATH, 'wb') do |file| + puts 'Downloading GEO-IP database...' + file << open(ARCHIVE_URL).read + end + + system("cd /tmp/ && unzip #{ARCHIVE_PATH}") + all_lines_count = 0 + File.open(SOURCE_FILE, 'r') {|file| all_lines_count = file.read.count("\n")} + + if all_lines_count < 100000 + puts "Too few lines: #{all_lines_count}" + return 0 + end + + GeoIpCountry.destroy_all + + lines = 0 + File.open(SOURCE_FILE, 'r').each_line do |line| + lines += 1 + + line_array = line.split(',') + parameters = { + :from => line_array[0].gsub('"','').strip, + :to => line_array[1].gsub('"','').strip, + :n_from => line_array[2].gsub('"','').to_i, + :n_to => line_array[3].gsub('"','').to_i, + :country_code => line_array[4].gsub('"','').strip, + :country_name => line_array[5].gsub('"','').strip + } + + percent = lines.to_f / all_lines_count.to_f * 100.0 + puts "#{all_lines_count} / #{lines} / #{percent.to_i}% / Processing #{parameters[:from]}-#{parameters[:to]} / #{parameters[:country_name]} " + area_code = GeoIpCountry.create(parameters) + end + end +end \ No newline at end of file -- cgit v1.2.3 From 26456e2298376ceb5bc3d7978d7c0aa146e44039 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 4 Jun 2013 14:05:00 +0200 Subject: Added to_s --- lib/freeswitch_event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/freeswitch_event.rb b/lib/freeswitch_event.rb index 89d8ea0..f17cd78 100644 --- a/lib/freeswitch_event.rb +++ b/lib/freeswitch_event.rb @@ -60,7 +60,7 @@ class FreeswitchEventSocket if ! body.blank? message['_BODY'] = body end - header.split("\n").each do |line| + header.to_s.split("\n").each do |line| key, value = line.split(/\: */, 2) message[key] = value end -- cgit v1.2.3