mirror of
https://github.com/webmin/webmin.git
synced 2026-06-05 04:40:24 +01:00
https://forum.virtualmin.com/t/editing-server-block-configure-nginx-website-does-not-reload-nginx/137282/16?u=ilia
49 lines
1.2 KiB
Perl
Executable File
49 lines
1.2 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
# Update one config file
|
|
|
|
use strict;
|
|
use warnings;
|
|
require './nginx-lib.pl';
|
|
&ReadParseMime();
|
|
our (%text, %in, %access);
|
|
&error_setup($text{'manual_err'});
|
|
&can_edit_manual_config() || &error($text{'manual_ecannot'});
|
|
|
|
my @files = &get_manual_config_files();
|
|
$in{'file'} = &resolve_manual_config_file($in{'file'}, @files) ||
|
|
&error($text{'manual_efile'});
|
|
|
|
$in{'data'} =~ s/\r//g;
|
|
my $fh = "CONF";
|
|
if ($in{'test'}) {
|
|
# Backup the file, write to it, and then test the config
|
|
my $temp = &transname();
|
|
©_source_dest($in{'file'}, $temp);
|
|
&open_lock_tempfile($fh, ">$in{'file'}");
|
|
&print_tempfile($fh, $in{'data'});
|
|
&close_tempfile($fh);
|
|
my $err = &test_config();
|
|
if ($err) {
|
|
# Bad config .. roll back
|
|
©_source_dest($temp, $in{'file'});
|
|
&unlink_file($temp);
|
|
&error(&text('restart_etest',
|
|
"<tt>".&html_escape($err)."</tt>"));
|
|
}
|
|
&unlink_file($temp);
|
|
}
|
|
else {
|
|
# Just write out
|
|
&open_lock_tempfile($fh, ">$in{'file'}");
|
|
&print_tempfile($fh, $in{'data'});
|
|
&close_tempfile($fh);
|
|
}
|
|
&update_last_config_change();
|
|
&webmin_log("manual", undef, $in{'file'});
|
|
if ($in{'id'}) {
|
|
&redirect(&nginx_submod_url("edit_server.cgi?id=".&urlize($in{'id'})));
|
|
}
|
|
else {
|
|
&redirect("index.cgi");
|
|
}
|