/
README
78 lines (52 loc) · 2.56 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Hetzner::Robot / hetzner-robot.pl
by Stefan Tomanek <stefan.tomanek@wertarbyte.de>
http://github.com/wertarbyte/hetzner-robot-perl
Control the Hetzner robot from your Perl scripts or console.
The script hetzner-robot.pl can be used as a standalone program as well as an
object oriented Perl module in your own scripts. It uses the JSON-Webservice
deployed by Hetzner (http://wiki.hetzner.de/index.php/Robot_Webservice) and
encapsulates it into a class/object structure. Many default operations are
provided through a command line interface.
== Examples for standalone operation ==
# retrieve reverse DNS entry for IP address 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode rdns --get --addr 1.2.3.4
# set reverse DNS entry for address 1.2.3.4 to "foobar.example.org"
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode rdns --set --addr 1.2.3.4 --hostname foobar.example.org
# instruct the hetzner robot to trigger a hardware reset at server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode reset --address 1.2.3.4 --method hw
# enable the rescue system for server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode rescue --address 1.2.3.4 --system linux --arch 64
# send Wake-On-LAN signal to system 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode wol --address 1.2.3.4
# switch failover address to server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode failover --address 5.6.7.8 --target 1.2.3.4
# retrieve status of a failover address
hetzner-robot.pl --user "USERNAME" --password "PASSWORD" \
--mode failover --address 5.6.7.8 --status
# to hide the password from the command line, it can be read from stdin:
echo "passphrase" | hetzner-robot.pl --user "USERNAME" --readpw ...
== Examples for use in scripts ==
#!/usr/bin/perl
# load module
use Hetzner::Robot;
my $robot = new Hetzner::Robot("username", "password");
my $serverA = $robot->server("1.2.3.4");
# enumerate subnets assigned to server
for my $n ($serverA->subnets) {
print $n->address."/".$n->netmask, "\n";
}
# send WOL signal to all servers
for my $sys ($robot->servers) {
print "Waking up ".$sys->address."\n";
$sys->wol->execute;
# $sys->reset->execute("sw"); # we could trigger a soft reboot as well ;-)
}
The examples directory also contains a simple CGI script to grant customers
limited access to the reverse DNS capabilities of the robot; each customer
can access the RDNS records of the addresses associated with their username.