mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 01:47:13 +00:00

This is a clutter-reduction step, separating the packaging and code-integrity checks from the stuff for maintaining mainline campaigns. I've also added documentation comments to some scripts.
54 lines
1011 B
Perl
Executable File
54 lines
1011 B
Perl
Executable File
#!/usr/bin/perl
|
|
#
|
|
# Set the passphrase for a campaign on the Wesnoth campaign server.
|
|
# You must know the old passphrase.
|
|
|
|
use wml;
|
|
use wml_net;
|
|
use strict;
|
|
|
|
my ($host, $port) = ("campaigns.wesnoth.org", 15003);
|
|
|
|
$| = 1;
|
|
|
|
print "Campaign name to change passphrase of: ";
|
|
my $name = <STDIN>;
|
|
chomp $name;
|
|
|
|
print "Old passphrase: ";
|
|
my $old = <STDIN>;
|
|
chomp $old;
|
|
|
|
print "New passphrase: ";
|
|
my $new = <STDIN>;
|
|
chomp $new;
|
|
|
|
my $socket = &wml_net::connect($host,$port);
|
|
|
|
if (!defined($socket)) {
|
|
print "Error connecting to the campaign server\n";
|
|
exit;
|
|
}
|
|
|
|
&wml_net::write_packet($socket,&wml::read_text( << "EOF" ));
|
|
[change_passphrase]
|
|
name=\"$name\"
|
|
passphrase=\"$old\"
|
|
new_passphrase=\"$new\"
|
|
[/change_passphrase]
|
|
EOF
|
|
|
|
my $response = &wml_net::read_packet($socket);
|
|
|
|
if (!defined($response)) {
|
|
print "Error accessing the campaign server.\n";
|
|
exit;
|
|
}
|
|
|
|
if (my $error = &wml::has_child($response, 'error')) {
|
|
printf "Error: %s\n", $error->{'attr'}->{'message'};
|
|
exit;
|
|
}
|
|
|
|
print "Passphrase updated.\n";
|