mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Start and stop buttons for iscsi target
This commit is contained in:
25
iscsi-target/atboot.cgi
Executable file
25
iscsi-target/atboot.cgi
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Change if the iscsi server is started at boot or not
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
&foreign_require("init");
|
||||
our (%text, %config, %in);
|
||||
&ReadParse();
|
||||
&error_setup($text{'atboot_err'});
|
||||
|
||||
my $old = &init::action_status($config{'init_name'});
|
||||
if ($old != 2 && $in{'boot'}) {
|
||||
# Enable at boot
|
||||
$old == 1 || &error(&text('atboot_einit',
|
||||
"<tt>$config{'init_name'}</tt>"));
|
||||
&init::enable_at_boot($config{'init_name'});
|
||||
&webmin_log("atboot");
|
||||
}
|
||||
elsif ($old == 2 && !$in{'boot'}) {
|
||||
# Disable at boot
|
||||
&init::disable_at_boot($config{'init_name'});
|
||||
&webmin_log("delboot");
|
||||
}
|
||||
&redirect("");
|
||||
@@ -154,7 +154,7 @@ print &ui_table_row($text{'target_iuser'},
|
||||
$utable);
|
||||
|
||||
# Outgoing user
|
||||
my $u = &find_value($conf, "OutgoingUser");
|
||||
my $u = &find_value($target->{'members'}, "OutgoingUser");
|
||||
my ($uname, $upass) = split(/\s+/, $u);
|
||||
print &ui_table_row($text{'target_ouser'},
|
||||
&ui_radio("ouser_def", $u ? 0 : 1,
|
||||
|
||||
@@ -21,6 +21,9 @@ return &text('check_econfig', "<tt>$config{'config_file'}</tt>")
|
||||
if (!-r $config{'config_file'});
|
||||
return &text('check_eietadm', "<tt>$config{'ietadm'}</tt>")
|
||||
if (!&has_command($config{'ietadm'}));
|
||||
&foreign_require("init");
|
||||
return &text('check_einit', "<tt>$config{'init_name'}</tt>")
|
||||
if (&init::action_status($config{'init_name'}) == 0);
|
||||
return undef;
|
||||
}
|
||||
|
||||
@@ -147,8 +150,8 @@ return ($indent ? "\t" : "").$dir->{'name'}." ".$dir->{'value'};
|
||||
sub find
|
||||
{
|
||||
my ($conf, $name) = @_;
|
||||
my @t = grep { lc($_->{'name'}) eq lc($name) } @$conf;
|
||||
return wantarray ? @t : $t[0];
|
||||
my @rv = grep { lc($_->{'name'}) eq lc($name) } @$conf;
|
||||
return wantarray ? @rv : $rv[0];
|
||||
}
|
||||
|
||||
# find_value(&config, name)
|
||||
@@ -156,10 +159,10 @@ return wantarray ? @t : $t[0];
|
||||
sub find_value
|
||||
{
|
||||
my ($conf, $name) = @_;
|
||||
return map { $_->{'value'} } &find($conf, $name);
|
||||
my @rv = map { $_->{'value'} } &find($conf, $name);
|
||||
return wantarray ? @rv : $rv[0];
|
||||
}
|
||||
|
||||
|
||||
# is_iscsi_target_running()
|
||||
# Returns the PID if the server process is running, or 0 if not
|
||||
sub is_iscsi_target_running
|
||||
@@ -172,6 +175,7 @@ return &check_pid_file($config{'pid_file'});
|
||||
sub find_host_name
|
||||
{
|
||||
my ($conf) = @_;
|
||||
my %hcount;
|
||||
foreach my $t (&find_value($conf, "Target")) {
|
||||
my ($host) = split(/:/, $t);
|
||||
$hcount{$host}++;
|
||||
@@ -189,4 +193,31 @@ return sprintf("iqn.%.4d-%.2d.%s", $tm[5]+1900, $tm[4]+1,
|
||||
join(".", reverse(split(/\./, &get_system_hostname()))));
|
||||
}
|
||||
|
||||
# start_iscsi_server()
|
||||
# Run the init script to start the server
|
||||
sub start_iscsi_server
|
||||
{
|
||||
&foreign_require("init");
|
||||
my ($ok, $out) = &init::start_action($config{'init_name'});
|
||||
return $ok ? undef : $out;
|
||||
}
|
||||
|
||||
# stop_iscsi_server()
|
||||
# Run the init script to stop the server
|
||||
sub stop_iscsi_server
|
||||
{
|
||||
&foreign_require("init");
|
||||
my ($ok, $out) = &init::stop_action($config{'init_name'});
|
||||
return $ok ? undef : $out;
|
||||
}
|
||||
|
||||
# restart_iscsi_server()
|
||||
# Run the init script to stop and then start the server
|
||||
sub restart_iscsi_server
|
||||
{
|
||||
&foreign_require("init");
|
||||
my ($ok, $out) = &init::restart_action($config{'init_name'});
|
||||
return $ok ? undef : $out;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
check_econfig=The iSCSI target configuration file $1 was not found on your system.
|
||||
check_eietadm=The iSCSI target administration command $1 was not found on your system.
|
||||
check_einit=Bootup action $1 does not exist
|
||||
|
||||
index_title=iSCSI Target
|
||||
index_clink=Maybe it is not installed, or your <a href='$1'>module configuration</a> is incorrect.
|
||||
@@ -59,3 +60,19 @@ 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
|
||||
manual_edata=No contents entered!
|
||||
|
||||
start_err=Failed to start iSCSI server
|
||||
stop_err=Failed to stop iSCSI server
|
||||
restart_err=Failed to restart iSCSI server
|
||||
atboot_err=Failed to enable at boot
|
||||
atboot_einit=Init script $1 does not exist
|
||||
|
||||
log_create_target=Created target $1
|
||||
log_delete_target=Deleted target $1
|
||||
log_modify_target=Modified target $1
|
||||
log_start=Started iSCSI server
|
||||
log_stop=Stopped iSCSI server
|
||||
log_restart=Restarted iSCSI server
|
||||
log_atboot=Enabled iSCSI server at boot time
|
||||
log_delboot=Disabled iSCSI server at boot time
|
||||
log_manual=Manually edited configuration file
|
||||
|
||||
18
iscsi-target/log_parser.pl
Executable file
18
iscsi-target/log_parser.pl
Executable file
@@ -0,0 +1,18 @@
|
||||
# log_parser.pl
|
||||
# Functions for parsing this module's logs
|
||||
|
||||
do 'iscsi-target-lib.pl';
|
||||
|
||||
# parse_webmin_log(user, script, action, type, object, ¶ms)
|
||||
# Converts logged information from this module into human-readable form
|
||||
sub parse_webmin_log
|
||||
{
|
||||
my ($user, $script, $action, $type, $object, $p) = @_;
|
||||
if ($type eq "target") {
|
||||
return &text('log_'.$action.'_'.$type, &html_escape($object));
|
||||
}
|
||||
else {
|
||||
return $text{'log_'.$action};
|
||||
}
|
||||
}
|
||||
|
||||
12
iscsi-target/restart.cgi
Executable file
12
iscsi-target/restart.cgi
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Stop and then re-start the iSCSI server process
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
our (%text);
|
||||
&error_setup($text{'restart_err'});
|
||||
my $err = &restart_iscsi_server();
|
||||
&error("<tt>".&html_escape($err)."</tt>") if ($err);
|
||||
&webmin_log("restart");
|
||||
&redirect("");
|
||||
@@ -7,6 +7,7 @@ require './iscsi-target-lib.pl';
|
||||
our (%text, %in);
|
||||
&ReadParse();
|
||||
&error_setup($text{'target_err'});
|
||||
&lock_file($config{'config_file'});
|
||||
my $conf = &get_iscsi_config();
|
||||
|
||||
# Get the target
|
||||
@@ -22,7 +23,7 @@ else {
|
||||
|
||||
if ($in{'delete'}) {
|
||||
# Delete the target
|
||||
# XXX
|
||||
&save_directive($conf, $conf, [ $target ], [ ]);
|
||||
}
|
||||
else {
|
||||
# Validate and save directives, starting with target name
|
||||
@@ -48,3 +49,9 @@ else {
|
||||
# Save the target
|
||||
# XXX
|
||||
}
|
||||
|
||||
&flush_file_lines($config{'config_file'});
|
||||
&unlock_file($config{'config_file'});
|
||||
&webmin_log($in{'delete'} ? 'delete' : $in{'new'} ? 'create' : 'modify',
|
||||
'target', $target->{'value'});
|
||||
&redirect("");
|
||||
|
||||
12
iscsi-target/start.cgi
Executable file
12
iscsi-target/start.cgi
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Start the iSCSI server process
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
our (%text);
|
||||
&error_setup($text{'start_err'});
|
||||
my $err = &start_iscsi_server();
|
||||
&error("<tt>".&html_escape($err)."</tt>") if ($err);
|
||||
&webmin_log("start");
|
||||
&redirect("");
|
||||
12
iscsi-target/stop.cgi
Executable file
12
iscsi-target/stop.cgi
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Kill the running iscsi server process
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-target-lib.pl';
|
||||
our (%text);
|
||||
&error_setup($text{'stop_err'});
|
||||
my $err = &stop_iscsi_server();
|
||||
&error($err) if ($err);
|
||||
&webmin_log("stop");
|
||||
&redirect("");
|
||||
Reference in New Issue
Block a user