Upgrade 3CX to v18 and get it hosted free!

Aastra Failsafe Reboot Script

Author image

I was unable to get “check-config” to work predictably so I wrote the following script:

#!/usr/bin/perl
#######################
#
# Simple script to reliably reset Aastra phones
# Kurt Heston – 20061014
#
#######################

use strict;
use warnings;
use LWP;

my $browser = LWP::UserAgent->new;
#my $ip = “192.168.0.61”;
my $ip = “$ARGV[0]”;

$browser->cookie_jar({});

# Replace ‘secret’ with password
$browser->credentials(
“$ip:80”,
‘Please enter User name and password’,
‘admin’ => ‘secret’
);

my $url = “http://$ip/reset.html”;

# Do a get so the phone can set a cookie
my $response = $browser->get( $url );

# Now send the reset command
$response = $browser->post( $url,
[‘resetOption’ => ‘0’]
);

die “$url error: “, $response->status_line
unless $response->is_success;

#print $response->content;

if( $response->content =~ m{Restarting the hardware} ) {
print “Phone at ” . $ip . ” restarted successfully\n”;
} else {
print “Phone at ” . $ip . ” not restarted\n”;
}

Shorter Examples

Using wget

wget –post-data=resetOption=0 –http-user=<username> –http-passwd=<password> http://ip.add.re.ss/reset.html^

The Aastra 57i’s tend to have a weird problem with sessions when using wget. It’s ugly but precede the above wget statement with this line TWICE:
wget –no-cache –http-user=<username> –http-passwd=<password> http://ip.add.re.ss/logout.html

The reason for needing to issue this command twice is due to the buggy method Aastra uses to verify authentication. – Ransak

Using curl

Assuming IP is 192.168.10.20, username is “admin” and password is “2222”:

  1. requesting page directly causes an unauthorized error
  2. workaround is to request the javascript first.

curl http://192.168.10.20/external.js

  1. the 2nd request actually does the reset…

curl -d resetOption=0 -u admin:22222 http://192.168.10.20/reset.html

See Also

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.