Stop / start / restart buttons

This commit is contained in:
Jamie Cameron
2012-09-05 17:40:45 -07:00
parent 6557945d13
commit aba1ddb400
6 changed files with 68 additions and 3 deletions

View File

@@ -28,8 +28,8 @@ print &ui_buttons_start();
# Show start/stop/restart buttons
my $pid = &is_iscsi_server_running();
if ($pid) {
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopdesc'});
print &ui_buttons_row("restart.cgi", $text{'index_restart'},
$text{'index_restartdesc'});
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopdesc'});
}

View File

@@ -202,6 +202,31 @@ sub is_iscsi_server_running
return &check_pid_file($config{'pid_file'});
}
# start_iscsi_server()
# Launch the iscsi server process, and return undef if successful
sub start_iscsi_server
{
my $out = &backquote_logged("$config{'iscsi_server'} -f $config{'targets_file'} 2>&1 </dev/null");
return $? ? $out : undef;
}
# stop_iscsi_server()
# Kill the running iscsi server process
sub stop_iscsi_server
{
my $pid = &is_iscsi_server_running();
return "Not running" if (!$pid);
return kill('TERM', $pid) ? undef : "Kill failed : $!";
}
# restart_iscsi_server()
# Kill and re-start the iscsi server process
sub restart_iscsi_server
{
&stop_iscsi_server();
return &start_iscsi_server();
}
# find_free_num(&config, type)
# Returns the max used device number of some type, plus 1
sub find_free_num

View File

@@ -7,8 +7,8 @@ index_stop=Stop iSCSI Server
index_stopdesc=Click this button to stop the running iSCSI server. All shared devices will no longer be accessible to clients.
index_start=Start iSCSI Server
index_startdesc=Click this button to start the iSCSI server, so that shared devices are accessible to clients.
index_restart=Click this button to apply the current configuration by restarting the iSCSI server.
index_restart=Restart iSCSI Server
index_restartdesc=Click this button to apply the current configuration by restarting the iSCSI server.
index_atboot=Start at boot?
index_atbootdesc=Change this option to control whether the iSCSI server is started at boot time or not. If it is not currently started at boot and Yes is chosen, a new init script will be created.
index_return=module index
@@ -78,3 +78,7 @@ targets_delete=Delete Selected Targets
desc_extent=Device to share $1
desc_device=Device combination $1
desc_target=Sharing target $1
start_err=Failed to start iSCSI server
stop_err=Failed to stop iSCSI server
restart_err=Failed to restart iSCSI server

12
iscsi-server/restart.cgi Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/local/bin/perl
# Stop and then re-start the iSCSI server process
use strict;
use warnings;
require './iscsi-server-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("");

12
iscsi-server/start.cgi Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/local/bin/perl
# Start the iSCSI server process
use strict;
use warnings;
require './iscsi-server-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-server/stop.cgi Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/local/bin/perl
# Kill the running iscsi server process
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text);
&error_setup($text{'stop_err'});
my $err = &stop_iscsi_server();
&error($err) if ($err);
&webmin_log("stop");
&redirect("");