mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Page to edit server IP address
This commit is contained in:
@@ -2,3 +2,4 @@ config_file=/etc/ietd.conf
|
||||
ietadm=ietadm
|
||||
pid_file=/var/run/iscsi_trgt.pid
|
||||
init_name=iscsitarget
|
||||
opts_file=/etc/sysconfig/iscsi-target
|
||||
|
||||
@@ -2,3 +2,4 @@ config_file=iSCSI target configuration file,0
|
||||
ietadm=Full path to ietadm command,0
|
||||
pid_file=Full path to PID file,0
|
||||
init_name=Bootup script name,0
|
||||
opts_file=File containing command line flags,0
|
||||
|
||||
36
iscsi-target/edit_addr.cgi
Normal file
36
iscsi-target/edit_addr.cgi
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show port and address options
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
our (%text);
|
||||
my $opts = &get_iscsi_options();
|
||||
|
||||
&ui_print_header(undef, $text{'addr_title'}, "");
|
||||
|
||||
print &ui_form_start("save_addr.cgi", "post");
|
||||
print &ui_table_start($text{'addr_header'}, undef, 2);
|
||||
|
||||
# Listen on address
|
||||
my $addr = $opts->{'a'} || $opts->{'address'};
|
||||
print &ui_table_row($text{'addr_addr'},
|
||||
&ui_opt_textbox("addr", $addr, 30,
|
||||
$text{'addr_any'}, $text{'addr_ip'}));
|
||||
|
||||
# Listen on port
|
||||
my $port = $opts->{'p'} || $opts->{'port'};
|
||||
print &ui_table_row($text{'addr_port'},
|
||||
&ui_opt_textbox("port", $port, 30, $text{'default'}." (3260)"));
|
||||
|
||||
# Debug level
|
||||
my $debug = $opts->{'d'} || $opts->{'debug'};
|
||||
print &ui_table_row($text{'addr_debug'},
|
||||
&ui_opt_textbox("debug", $debug, 5, $text{'addr_debugnone'}));
|
||||
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
@@ -64,14 +64,20 @@ print &ui_hr();
|
||||
my @links = ( "edit_auth.cgi",
|
||||
"edit_conn.cgi",
|
||||
"edit_timeout.cgi",
|
||||
"edit_addr.cgi",
|
||||
"list_clients.cgi",
|
||||
"edit_manual.cgi" );
|
||||
my @titles = ( $text{'auth_title'},
|
||||
$text{'conn_title'},
|
||||
$text{'timeout_title'},
|
||||
$text{'addr_title'},
|
||||
$text{'clients_title'},
|
||||
$text{'manual_title'} );
|
||||
my @icons = ( "images/auth.gif",
|
||||
"images/conn.gif",
|
||||
"images/timeout.gif",
|
||||
"images/addr.gif",
|
||||
"images/clients.gif",
|
||||
"images/manual.gif" );
|
||||
&icons_table(\@links, \@titles, \@icons);
|
||||
|
||||
|
||||
@@ -270,4 +270,86 @@ my ($ok, $out) = &init::restart_action($config{'init_name'});
|
||||
return $ok ? undef : $out;
|
||||
}
|
||||
|
||||
# get_iscsi_options_file()
|
||||
# Returns the file containing command-line options, for use when locking
|
||||
sub get_iscsi_options_file
|
||||
{
|
||||
return $config{'opts_file'};
|
||||
}
|
||||
|
||||
# get_iscsi_options_string()
|
||||
# Returns all flags as a string
|
||||
sub get_iscsi_options_string
|
||||
{
|
||||
my $file = &get_iscsi_options_file();
|
||||
my %env;
|
||||
&read_env_file($file, \%env);
|
||||
return $env{'OPTIONS'};
|
||||
}
|
||||
|
||||
# get_iscsi_options()
|
||||
# Returns a hash ref of command line options
|
||||
sub get_iscsi_options
|
||||
{
|
||||
my $str = &get_iscsi_options_string();
|
||||
my %opts;
|
||||
while($str =~ /\S/) {
|
||||
if ($str =~ /^\s*\-(c|d|g|a|p|u)\s+(\S+)(.*)/) {
|
||||
# Short arg, like -p 123
|
||||
$str = $3;
|
||||
$opts{$1} = $2;
|
||||
}
|
||||
elsif ($str =~ /^\s*\--(config|debug|address|port)=(\S+)(.*)/) {
|
||||
# Long arg, like --address=5.5.5.5
|
||||
$str = $3;
|
||||
$opts{$1} = $2;
|
||||
}
|
||||
elsif ($str =~ /^\s*\-((f)+)(.*)/) {
|
||||
# Arg with no value, like -f
|
||||
$str = $3;
|
||||
foreach my $o (split(//, $1)) {
|
||||
$opts{$o} = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
&error("Unknown option $str");
|
||||
}
|
||||
}
|
||||
return \%opts;
|
||||
}
|
||||
|
||||
# save_iscsi_options_string(str)
|
||||
# Update the options file with command line options from a string
|
||||
sub save_iscsi_options_string
|
||||
{
|
||||
my ($str) = @_;
|
||||
my $file = &get_iscsi_options_file();
|
||||
my %env;
|
||||
&read_env_file($file, \%env);
|
||||
$env{'OPTIONS'} = $str;
|
||||
&write_env_file($file, \%env);
|
||||
}
|
||||
|
||||
# save_iscsi_options(&opts)
|
||||
# Update the options file with command line options from a hash
|
||||
sub save_iscsi_options
|
||||
{
|
||||
my ($opts) = @_;
|
||||
my @str;
|
||||
foreach my $o (keys %$opts) {
|
||||
if ($opts->{$o} eq "") {
|
||||
push(@str, "-".$o);
|
||||
}
|
||||
elsif (length($o) == 1) {
|
||||
push(@str, "-".$o." ".$opts->{$o});
|
||||
}
|
||||
else {
|
||||
push(@str, "--".$o."=".$opts->{$o});
|
||||
}
|
||||
}
|
||||
&save_iscsi_options_string(join(" ", @str));
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -104,6 +104,21 @@ timeout_secs=seconds
|
||||
timeout_nopt=Time to wait for ping response
|
||||
timeout_noptnone=Same as ping time
|
||||
|
||||
addr_title=Server Address
|
||||
addr_header=iSCSI server networking options
|
||||
addr_addr=Listen on IP address
|
||||
addr_any=Any address
|
||||
addr_ip=IP
|
||||
addr_port=Listen on port
|
||||
addr_debug=Debug level
|
||||
addr_debugnone=Debugging disabled
|
||||
addr_err=Failed to save server address
|
||||
addr_eaddr=Address to listen on must be an IP address
|
||||
addr_eport=Port to listen on must be a number
|
||||
addr_edebug=Debug level must be a number
|
||||
|
||||
clients_title=Client Connections
|
||||
|
||||
manual_title=Edit Configuration File
|
||||
manual_desc=Use the text box below to edit the iSCSI server configuration file $1. Be careful, as no validation will be performed on your input!
|
||||
manual_err=Failed to save configuration file
|
||||
@@ -127,3 +142,4 @@ log_manual=Manually edited configuration file
|
||||
log_auth=Changed global authentication settings
|
||||
log_conn=Changed global connection settings
|
||||
log_timeout=Changed global timeout settings
|
||||
log_addr=Changed server address
|
||||
|
||||
40
iscsi-target/save_addr.cgi
Normal file
40
iscsi-target/save_addr.cgi
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Save networking options
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
our (%text, %in, %config);
|
||||
&ReadParse();
|
||||
&error_setup($text{'addr_err'});
|
||||
&lock_file($config{'opts_file'});
|
||||
my $opts = &get_iscsi_options();
|
||||
|
||||
# Listen on address
|
||||
delete($opts->{'a'});
|
||||
delete($opts->{'address'});
|
||||
if (!$in{'addr_def'}) {
|
||||
&check_ipaddress($in{'addr'}) || &error($text{'addr_eaddr'});
|
||||
$opts->{'a'} = $in{'addr'};
|
||||
}
|
||||
|
||||
# Listen on port
|
||||
delete($opts->{'p'});
|
||||
delete($opts->{'port'});
|
||||
if (!$in{'port_def'}) {
|
||||
$in{'port'} =~ /^\d+$/ || &error($text{'addr_eport'});
|
||||
$opts->{'p'} = $in{'port'};
|
||||
}
|
||||
|
||||
# Debug level
|
||||
delete($opts->{'d'});
|
||||
delete($opts->{'debug'});
|
||||
if (!$in{'debug_def'}) {
|
||||
$in{'debug'} =~ /^\d+$/ || &error($text{'addr_edebug'});
|
||||
$opts->{'d'} = $in{'debug'};
|
||||
}
|
||||
|
||||
&save_iscsi_options($opts);
|
||||
&unlock_file($config{'opts_file'});
|
||||
&webmin_log('addr');
|
||||
&redirect("");
|
||||
Reference in New Issue
Block a user