summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rwxr-xr-xscript/agi_server35
-rwxr-xr-xscript/delayed_job5
-rwxr-xr-xscript/erd38
-rwxr-xr-xscript/fax_new111
-rwxr-xr-xscript/fax_new.sh4
-rwxr-xr-xscript/logout_phones29
-rwxr-xr-xscript/logout_phones.sh4
-rwxr-xr-xscript/notes25
-rwxr-xr-xscript/rails68
-rwxr-xr-xscript/voicemail_new61
-rwxr-xr-xscript/voicemail_new.sh4
11 files changed, 384 insertions, 0 deletions
diff --git a/script/agi_server b/script/agi_server
new file mode 100755
index 0000000..0a0fd76
--- /dev/null
+++ b/script/agi_server
@@ -0,0 +1,35 @@
+#! /usr/bin/env ruby
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require APP_PATH
+
+begin
+ Rails.application.require_environment!
+rescue ActiveRecord::AdapterNotSpecified => e
+ $stderr.puts "No such Rails environment: \"#{Rails.env}\"."
+ exit 1
+end
+
+begin
+ require 'agi_server'
+ server_instance = AGIServer::server()
+
+rescue SignalException => e
+ case e.signo
+ when 1
+ $stderr.puts "Signal 1 caught, exiting"
+ when 2
+ $stderr.puts "Interrupt signal caught, exiting"
+ when 15
+ $stderr.puts "Exit signal caught, exiting"
+ else
+ $stderr.print "#{e.class.to_s}"
+ $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
+ end
+ $stderr.puts ""
+ exit (e.signo + 128)
+end
+
+exit 0
+
diff --git a/script/delayed_job b/script/delayed_job
new file mode 100755
index 0000000..edf1959
--- /dev/null
+++ b/script/delayed_job
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize
diff --git a/script/erd b/script/erd
new file mode 100755
index 0000000..5ba938c
--- /dev/null
+++ b/script/erd
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+echo ""
+echo "### Generating Dot file ..."
+bundle exec \
+ rake erd filetype=dot \
+ attributes=content,foreign_keys \
+ indirect=true \
+ orientation=horizontal \
+ notation=simple
+
+if which dot; then
+ echo ""
+ echo "### Generating PDF file (via dot) ..."
+ dot -Tpdf:quartz:quartz -o ERD.pdf ERD.dot
+else
+ if which graphviz; then
+ echo ""
+ echo "### Generating PDF file (via graphviz) ..."
+ bundle exec \
+ rake erd filetype=pdf \
+ attributes=content,foreign_keys \
+ indirect=true \
+ orientation=horizontal \
+ notation=simple
+ else
+ echo "No dot no PDF."
+ fi
+fi
+
+if which dot; then
+ echo ""
+ echo "### Generating PNG file (via dot) ..."
+ dot -Tpng:quartz:quartz -o ERD.png ERD.dot
+else
+ echo "No dot no PNG."
+fi
+
diff --git a/script/fax_new b/script/fax_new
new file mode 100755
index 0000000..8015da8
--- /dev/null
+++ b/script/fax_new
@@ -0,0 +1,111 @@
+#! /usr/bin/env ruby
+
+begin
+
+if !ARGV[0] or ARGV[0] == '' or !ARGV[10] or ARGV[10] == ''
+ $stderr.puts "usage: fax_new <fax_account_id> \
+<result_code> \
+<document_total_pages> \
+<document_transferred_pages> \
+<ecm_requested> \
+<ecm_used> \
+<image_resolution> \
+<remote_station_id> \
+<transfer_rate> \
+<transmission_time> \
+<document> \
+<caller_id_number> \
+<caller_id_name>"
+ exit 1
+end
+
+fax_arguments = {
+ :fax_account_id => ARGV[0],
+ :result_code => ARGV[1],
+ :document_total_pages => ARGV[2],
+ :document_transferred_pages => ARGV[3],
+ :ecm_requested => ARGV[4],
+ :ecm_used => ARGV[5],
+ :image_resolution => ARGV[6],
+ :remote_station_id => ARGV[7],
+ :transfer_rate => ARGV[8],
+ :transmission_time => ARGV[9],
+ :document => ARGV[10],
+ :caller_id_number => ARGV[11],
+ :caller_id_name => ARGV[12],
+}
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require APP_PATH
+
+begin
+ Rails.application.require_environment!
+rescue ActiveRecord::AdapterNotSpecified => e
+ error "No such Rails environment: \"#{Rails.env}\"."
+ exit 1
+end
+
+TIFF_FUFFIX = ".tiff"
+PDF_SUFFIX = ".pdf"
+
+tiff_file = fax_arguments[:document]
+
+if !tiff_file or !File.exists?( tiff_file )
+ $stderr.puts "File \"#{tiff_file}\" does not exist"
+ exit 1
+end
+
+paper_size = "letter"
+pdf_file = "#{File.dirname(tiff_file)}/#{File.basename(tiff_file, TIFF_FUFFIX)}#{PDF_SUFFIX}"
+
+system "tiff2pdf \\
+ -o \"#{pdf_file}\" \\
+ -p #{paper_size} \\
+ -a \"#{fax_arguments[:remote_station_id]}\" \\
+ -c \"AMOOMA Gemeinschaft version #{GEMEINSCHAFT_VERSION}\" \\
+ -t \"#{fax_arguments[:remote_station_id]}\" \"#{tiff_file}\""
+
+if !File.exists?( pdf_file )
+ $stderr.puts "File \"#{pdf_file}\" does not exist"
+ exit 1
+end
+
+fax_account = FaxAccount.find(fax_arguments[:fax_account_id])
+if !fax_account
+ $stderr.puts "Fax account \"#{fax_arguments[:fax_account_id]}\" does not exist"
+ exit 1
+end
+
+fax_arguments[:document] = nil
+fax_arguments[:success] = true
+fax_arguments[:inbound] = true
+fax_arguments[:sent_at] = Time.now
+fax_arguments[:local_station_id] = fax_account.station_id
+fax_arguments[:retry_counter] = 0
+fax_arguments[:fax_resolution_id] = FaxResolution.first.id
+fax_arguments[:image_size] = File.size(tiff_file)
+fax_arguments[:ecm_used] = fax_arguments[:ecm_used] == "on" ? true : false
+fax_document = fax_account.fax_documents.build(fax_arguments)
+fax_document.document = File.open(pdf_file)
+
+if ! fax_document.save
+ $stderr.puts "Error(s) creating fax document:"
+ $stderr.puts fax_document.errors.inspect
+ exit 1
+end
+
+fax_document.mark_as_inbound!
+
+Notifications.new_fax(fax_document).deliver
+
+exit 0
+
+rescue SignalException => e
+ $stderr.print "#{e.class.to_s}"
+ $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
+ $stderr.puts ""
+ exit 130
+end
+
+exit 0
diff --git a/script/fax_new.sh b/script/fax_new.sh
new file mode 100755
index 0000000..3c98d41
--- /dev/null
+++ b/script/fax_new.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+cd /opt/GS5/script/
+source /usr/local/rvm/scripts/rvm
+/opt/GS5/script/fax_new "$@"
diff --git a/script/logout_phones b/script/logout_phones
new file mode 100755
index 0000000..2a1f266
--- /dev/null
+++ b/script/logout_phones
@@ -0,0 +1,29 @@
+#! /usr/bin/env ruby
+
+begin
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require APP_PATH
+
+begin
+ Rails.application.require_environment!
+rescue ActiveRecord::AdapterNotSpecified => e
+ error "No such Rails environment: \"#{Rails.env}\"."
+ exit 1
+end
+
+phones = Phone.where(:nightly_reboot => true).each do |phone|
+ if ! phone.user_logout
+ $stderr.puts "#{phone.id} #{phone.mac_address} - #{phone.errors.messages.inspect}"
+ end
+end
+
+rescue SignalException => e
+ $stderr.print "#{e.class.to_s}"
+ $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
+ $stderr.puts ""
+ exit 130
+end
+
+exit 0
diff --git a/script/logout_phones.sh b/script/logout_phones.sh
new file mode 100755
index 0000000..2a1a54e
--- /dev/null
+++ b/script/logout_phones.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+cd /opt/GS5/script/
+source /usr/local/rvm/scripts/rvm
+/opt/GS5/script/logout_phones $@
diff --git a/script/notes b/script/notes
new file mode 100755
index 0000000..1285884
--- /dev/null
+++ b/script/notes
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+# `rake notes` doesn't find everything and is too slow.
+
+#find . -type f \
+# | grep -vEe '/(\.git|\.DS_Store|\.idea/|\.project|doc/app/|script/notes|log/|debian/visual-inspection/|public/javascripts/controls\.js)' \
+# | xargs grep --color -IEe '# *(FIXME|TODO|OPTIMIZE)'
+#exit 0
+
+find . -not \( \
+ -name '.svn' -prune -o \
+ -name '.git' -prune -o \
+ -name '.DS_Store' -prune -o \
+ -name '.idea' -prune -o \
+ -name '.project' -prune -o \
+ -path '*/script/notes' -prune -o \
+ -path '*/doc/app/*' -prune -o \
+ -path '*/doc/html-onefile/*.html' -prune -o \
+ -path '*/doc/docbook-xsl-*' -prune -o \
+ -path '*/public/javascripts/controls.js' -prune -o \
+ -path '*/log/*.log' -prune -o \
+ -false \
+ \) -type f -print0 \
+ | xargs -0 grep --color -IEe '#[^#]*(FIXME|TODO|OPTIMIZE)\b.*'
+
diff --git a/script/rails b/script/rails
new file mode 100755
index 0000000..5f16f40
--- /dev/null
+++ b/script/rails
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+
+
+# # ---[ Custom stuff ]--------------------------------------{
+# # Start web server with SSL enabled.
+# # http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html
+#
+# require 'rubygems'
+# require 'rails/commands/server'
+# require 'rack'
+#
+# # like WEBrick::Utils::getservername()
+# def getservername()
+# return 'abc'
+# require 'socket'
+# host = Socket::gethostname
+# begin
+# return Socket::gethostbyname(host)[0]
+# rescue
+# return host
+# end
+# end
+#
+# require 'webrick'
+# require 'webrick/https'
+#
+# module Rails
+# class Server < ::Rack::Server
+# # http://api.rubyonrails.org/classes/Rails/Server.html#method-i-default_options
+# def default_options
+# super.merge({
+# :Port => 3001,
+# # https://github.com/raesene/dradisframework/commit/705d067eb9eef9ac98de29439757a0b1102c15cc
+# :DoNotReverseLookup => true,
+# :environment => (ENV['RAILS_ENV'] || 'development').dup,
+# :daemonize => false,
+# :debugger => false,
+# :pid => File.expand_path( 'tmp/pids/server.pid' ),
+# :config => File.expand_path( 'config.ru' ),
+# :SSLEnable => true,
+# :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+# :SSLPrivateKey => OpenSSL::PKey::RSA.new(
+# File.open( 'misc/etc/ssl/amooma/server_key.pem' ).read),
+# :SSLCertificate => OpenSSL::X509::Certificate.new(
+# File.open( 'misc/etc/ssl/amooma/server_cert.pem' ).read),
+# :SSLCertName => [[ 'CN', getservername() ]],
+# })
+# end
+# end
+# end
+#
+# # require 'rack/handler'
+# # Rack::Handler.class_eval do
+# # def self.default( options = {} )
+# # Rack::Handler::Thin
+# # end
+# # end
+#
+# # ---------------------------------------------------------}
+#
+
+
+require 'rails/commands'
+
diff --git a/script/voicemail_new b/script/voicemail_new
new file mode 100755
index 0000000..bfdf39f
--- /dev/null
+++ b/script/voicemail_new
@@ -0,0 +1,61 @@
+#! /usr/bin/env ruby
+
+begin
+
+if !ARGV[0] or ARGV[0] == '' or !ARGV[1] or ARGV[1] == ''
+ $stderr.puts "usage: voicemail_new <account_name> <voicemail_uuid>"
+ exit 1
+end
+
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require APP_PATH
+
+begin
+ Rails.application.require_environment!
+rescue ActiveRecord::AdapterNotSpecified => e
+ error "No such Rails environment: \"#{Rails.env}\"."
+ exit 1
+end
+
+voicemail_account_name = ARGV[0]
+uuid = ARGV[1]
+
+message = FreeswitchVoicemailMsg.where(:username => voicemail_account_name, :uuid => uuid).first
+
+if ! message
+ $stderr.puts "Message \"#{uuid}\" does not exist"
+ exit 1
+end
+
+if !File.exists?( message.file_path )
+ $stderr.puts "File \"#{message.file_path}\" does not exist"
+ exit 1
+end
+
+owner_account = SipAccount.where(:auth_name => voicemail_account_name).first
+if ! owner_account
+ $stderr.puts "SipAccount \"#{voicemail_account_name}\" does not exist"
+ exit 1
+end
+
+sip_account = SipAccount.find_by_auth_name(message.username)
+if sip_account && sip_account.sip_accountable.class == User
+ user = sip_account.sip_accountable
+
+ if user.send_voicemail_as_email_attachment == true
+ if Notifications.new_voicemail(message).deliver
+ message.delete
+ end
+ end
+end
+
+rescue SignalException => e
+ $stderr.print "#{e.class.to_s}"
+ $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
+ $stderr.puts ""
+ exit 130
+end
+
+exit 0
diff --git a/script/voicemail_new.sh b/script/voicemail_new.sh
new file mode 100755
index 0000000..dcb29f5
--- /dev/null
+++ b/script/voicemail_new.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+source /usr/local/rvm/scripts/rvm
+/opt/GS5/script/voicemail_new $@