Last active
February 5, 2019 16:32
-
-
Save amboxer21/96f63443ac7d2a611212b4cd05101c9f to your computer and use it in GitHub Desktop.
Randomly calls the new guys every 10 minutes via cron script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
require 'net/ssh' | |
require 'optparse' | |
ASTERISK_RX = '/usr/sbin/asterisk -rx ' | |
@rand = Random.rand(1..3) | |
@user = {1 => ['270','cell phone number goes here'], | |
2 => ['182','cell phone number goes here'], | |
3 => ['288','cell phone number goes here']} #Tyler, Jon, Tom | |
@option = {:server => nil, :username => nil, :password => nil} | |
optparse = OptionParser.new do |opts| | |
opts.banner = "Usage: rand_dialer.rb --server <server> --username <username> --password <password> " | |
opts.on( '-s', '--server server', 'server') do |server| | |
@option[:server] = server | |
end | |
opts.on( '-u', '--username username', 'username') do |username| | |
@option[:username] = username | |
end | |
opts.on( '-p', '--password password', 'password') do |password| | |
@option[:password] = password | |
end | |
end | |
optparse.parse! | |
if @option[:username].nil? or @option[:password].nil? or @option[:server].nil? | |
puts optparse.banner | |
exit | |
end | |
def tunnel(server,username,password,ast_command) | |
begin | |
Net::SSH.start(server, username, :password => password) do |ssh| | |
ssh.exec!("#{ASTERISK_RX}'#{ast_command}'") | |
end | |
rescue Exception => e | |
puts "Exception e => #{e}" | |
puts "Unable to connect to #{server} using #{username}/#{password}" | |
end | |
end | |
@user = @user[@rand] | |
tunnel(@option[:server],@option[:username],@option[:password], | |
"channel originate sip/1#{@user[1]}@mg5 extension #{@user[0]}@outbound-mttpbx\"") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment