Aastra Failsafe Reboot Script

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


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


Created by: kheston, Last modification: Sun 16 of Mar, 2008 (22:09 UTC) by jmoore
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+