mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Complete saving of config options
This commit is contained in:
@@ -12,10 +12,10 @@ our (%text, %config, %in);
|
||||
my $old = &init::action_status($config{'init_name'});
|
||||
if ($old != 2 && $in{'boot'}) {
|
||||
# Enable at boot
|
||||
if (!-r $config{'opts_file'}) {
|
||||
my $fh = "OPTS";
|
||||
&open_tempfile($fh, ">$config{'opts_file'}");
|
||||
&close_tempfile($fh);
|
||||
my $str = &get_iscsi_options_string();
|
||||
if (!$str) {
|
||||
# Force creation of environment variable file
|
||||
&save_iscsi_options_string("");
|
||||
}
|
||||
&init::enable_at_boot($config{'init_name'},
|
||||
"Start or stop the iSCSI server",
|
||||
|
||||
@@ -375,6 +375,13 @@ foreach my $n (@names) {
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# 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
|
||||
@@ -408,8 +415,21 @@ while($str =~ /\S/) {
|
||||
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 %env;
|
||||
&lock_file($config{'opts_file'});
|
||||
&read_env_file($config{'opts_file'}, \%env);
|
||||
$env{'NETBSD_ISCSI_OPTS'} = $str;
|
||||
&write_env_file($config{'opts_file'}, \%env);
|
||||
&unlock_file($config{'opts_file'});
|
||||
}
|
||||
|
||||
# save_iscsi_options(&opts)
|
||||
# Update the options file or init script and built-in config
|
||||
# Update the options file with command line options from a hash
|
||||
sub save_iscsi_options
|
||||
{
|
||||
my ($opts) = @_;
|
||||
@@ -422,15 +442,7 @@ foreach my $o (keys %$opts) {
|
||||
push(@str, "-".$o." ".$opts->{$o});
|
||||
}
|
||||
}
|
||||
my $str = join(" ", @str);
|
||||
|
||||
# Save in an environment file
|
||||
my %env;
|
||||
&lock_file($config{'opts_file'});
|
||||
&read_env_file($config{'opts_file'}, \%env);
|
||||
$env{'NETBSD_ISCSI_OPTS'} = $str;
|
||||
&write_env_file($config{'opts_file'}, \%env);
|
||||
&unlock_file($config{'opts_file'});
|
||||
&save_iscsi_options_string(join(" ", @str));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
require './iscsi-server-lib.pl';
|
||||
our (%text, %config);
|
||||
our (%text, %config, %in);
|
||||
&ReadParse();
|
||||
&error_setup($text{'opts_err'});
|
||||
|
||||
&lock_file(&get_iscsi_options_file());
|
||||
my $opts = &get_iscsi_options();
|
||||
|
||||
# IPv4 enabled?
|
||||
@@ -55,8 +57,8 @@ else {
|
||||
$opts->{'s'} = $in{'sess'};
|
||||
}
|
||||
|
||||
# XXX locking?
|
||||
&save_iscsi_options($opts);
|
||||
&unlock_file(&get_iscsi_options_file());
|
||||
&webmin_log("opts");
|
||||
&redirect("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user