* Updated all System->*_daemon methods to not append '.service' to the daemon parameter. Also make all daemon names variables stored in 'sys::daemon::<foo>' and updated existing calls to these methods to use those variables.

* Got anvil-manage-install-target finished creating config files and enabling daemons needed for PXE. Still untested in function though.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 6f5541b6fd
commit 45f290d5e7
  1. 18
      Anvil/Tools.pm
  2. 8
      Anvil/Tools/Database.pm
  3. 3
      Anvil/Tools/Storage.pm
  4. 68
      Anvil/Tools/System.pm
  5. 36
      notes
  6. 4
      share/words.xml
  7. 167
      tools/anvil-manage-install-target
  8. 8
      tools/anvil-prep-database

@ -736,6 +736,13 @@ sub _set_defaults
apache => {
user => "admin",
},
daemon => {
dhcpd => "dhcpd.service",
firewalld => "firewalld.service",
httpd => "httpd.service",
postgresql => "postgresql.service",
tftp => "tftp.socket",
},
daemons => {
restart_firewalld => 1,
},
@ -791,9 +798,6 @@ sub _set_defaults
hash_count => 500000,
salt_length => 16,
},
service => {
postgresql => "postgresql",
},
terminal => {
columns => 80,
stty => "",
@ -890,7 +894,9 @@ sub _set_paths
configs => {
'anvil.conf' => "/etc/anvil/anvil.conf",
'anvil.version' => "/etc/anvil/anvil.version",
dhcpd_conf => "/etc/dhcp/dhcpd.conf",
'autoindex.conf' => "/etc/httpd/conf.d/autoindex.conf",
'dhcpd.conf' => "/etc/dhcp/dhcpd.conf",
'dnf.conf' => "/etc/dnf/dnf.conf",
'firewalld.conf' => "/etc/firewalld/firewalld.conf",
'httpd.conf' => "/etc/httpd/conf/httpd.conf",
'journald_anvil' => "/etc/systemd/journald.conf.d/anvil.conf",
@ -988,6 +994,10 @@ sub _set_paths
sql => {
'anvil.sql' => "/usr/share/anvil/anvil.sql",
},
systemd => {
httpd_enabled_symlink => "/etc/systemd/system/multi-user.target.wants/httpd.service",
tftp_enabled_symlink => "/etc/systemd/system/sockets.target.wants/tftp.socket",
},
urls => {
skins => "/skins",
},

@ -243,7 +243,7 @@ sub configure_pgsql
}
# First, is it running?
my $running = $anvil->System->check_daemon({debug => $debug, daemon => "postgresql"});
my $running = $anvil->System->check_daemon({debug => $debug, daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { running => $running }});
if (not $running)
@ -268,7 +268,7 @@ sub configure_pgsql
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0055"});
# Enable it on boot.
my $return_code = $anvil->System->enable_daemon({debug => $debug, daemon => "postgresql"});
my $return_code = $anvil->System->enable_daemon({debug => $debug, daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { return_code => $return_code }});
}
}
@ -380,7 +380,7 @@ sub configure_pgsql
if (not $running)
{
# Start the daemon.
my $return_code = $anvil->System->start_daemon({daemon => "postgresql"});
my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { return_code => $return_code }});
if ($return_code eq "0")
{
@ -397,7 +397,7 @@ sub configure_pgsql
elsif (($update_postgresql_file) or ($update_pg_hba_file))
{
# Reload
my $return_code = $anvil->System->start_daemon({daemon => "postgresql"});
my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { return_code => $return_code }});
if ($return_code eq "0")
{

@ -2123,9 +2123,10 @@ sub update_file
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0233", variables => { file => $file, 'return' => $return }});
return(0);
}
return(1);
}
return(1);
return(2);
}
=head2 write_file

@ -424,7 +424,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to check.
This is the name of the daemon to check. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub check_daemon
@ -435,12 +435,11 @@ sub check_daemon
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_daemon()" }});
my $return = 2;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
my $return = 2;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$say_daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});
foreach my $line (split/\n/, $output)
{
@ -600,7 +599,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to enable.
This is the name of the daemon to enable. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub enable_daemon
@ -613,10 +612,9 @@ sub enable_daemon
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." enable ".$say_daemon." 2>&1; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." enable ".$daemon." 2>&1; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});
foreach my $line (split/\n/, $output)
{
@ -1294,14 +1292,14 @@ sub manage_firewall
}
# Make sure firewalld is running.
my $firewalld_running = $anvil->System->check_daemon({daemon => "firewalld"});
my $firewalld_running = $anvil->System->check_daemon({daemon => $anvil->data->{sys}{daemon}{firewalld}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { firewalld_running => $firewalld_running }});
if (not $firewalld_running)
{
if ($anvil->data->{sys}{daemons}{restart_firewalld})
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0127"});
my $return_code = $anvil->System->start_daemon({daemon => "firewalld"});
my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{firewalld}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { return_code => $return_code }});
if ($return_code)
{
@ -1507,7 +1505,7 @@ sub manage_firewall
# If we made a change, reload.
if ($changed)
{
$anvil->System->reload_daemon({daemon => "firewalld"});
$anvil->System->reload_daemon({daemon => $anvil->data->{sys}{daemon}{firewalld}});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'open' => $open }});
@ -1915,7 +1913,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to reload.
This is the name of the daemon to reload. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub reload_daemon
@ -1925,12 +1923,11 @@ sub reload_daemon
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $shell_call = $anvil->data->{path}{exe}{systemctl}." reload ".$say_daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?";
my $shell_call = $anvil->data->{path}{exe}{systemctl}." reload ".$daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $output = $anvil->System->call({shell_call => $shell_call});
@ -2045,7 +2042,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to restart.
This is the name of the daemon to restart. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub restart_daemon
@ -2055,12 +2052,11 @@ sub restart_daemon
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $shell_call = $anvil->data->{path}{exe}{systemctl}." restart ".$say_daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?";
my $shell_call = $anvil->data->{path}{exe}{systemctl}." restart ".$daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $output = $anvil->System->call({shell_call => $shell_call});
@ -2088,7 +2084,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to start.
This is the name of the daemon to start. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub start_daemon
@ -2099,12 +2095,11 @@ sub start_daemon
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->start_daemon()" }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$say_daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?", debug => $debug});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?", debug => $debug});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});
foreach my $line (split/\n/, $output)
{
@ -2130,7 +2125,7 @@ Parameters;
=head3 daemon (required)
This is the name of the daemon to stop.
This is the name of the daemon to stop. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=cut
sub stop_daemon
@ -2141,12 +2136,11 @@ sub stop_daemon
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->stop_daemon()" }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
my $say_daemon = $daemon =~ /\.service$/ ? $daemon : $daemon.".service";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon, say_daemon => $say_daemon }});
my $return = undef;
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." stop ".$say_daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." stop ".$daemon."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$?"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});
foreach my $line (split/\n/, $output)
{

36
notes

@ -1,8 +1,3 @@
# Add to /etc/dnf/dnf.conf
keepcache=1
skip_if_unavailable=1
Firewall config stuff.
====
---- Files
@ -89,43 +84,14 @@ https://docs.fedoraproject.org/en-US/fedora/f28/install-guide/advanced/Network_b
UEFI PXE notes - https://www.syslinux.org/wiki/index.php?title=PXELINUX#UEFI
dnf install dhcp tftp-server syslinux kernel-core
----
cat /etc/dhcp/dhcpd.conf
### Global options
option domain-name "alteeve.com"; # domain name
option domain-name-servers 8.8.8.8, 8.8.4.4; #
authoritative;
ddns-update-style none;
subnet 10.1.0.0 netmask 255.255.0.0 {
default-lease-time 600;
max-lease-time 7200;
range 10.1.14.1 10.1.14.254;
option routers 10.1.4.1;
}
----
# NOTE: We DON'T enable DHCP. We'll turn it on as needed.
# NOTE: Apache needs to show dot-files! (anaconda looks for .treeinfo)
====
[root@f28-striker01 conf.d]# pwd
/etc/httpd/conf.d
[root@f28-striker01 conf.d]# diff -u autoindex.conf.original autoindex.conf
--- autoindex.conf.original 2018-10-13 03:37:00.084687783 -0400
+++ autoindex.conf 2018-10-13 03:37:41.479635314 -0400
@@ -89,5 +89,6 @@
# IndexIgnore is a set of filenames which directory indexing should ignore
# and not include in the listing. Shell-style wildcarding is permitted.
#
-IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
+#IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
+IndexIgnore *~ *# HEADER* README* RCS CVS *,v *,t
====
systemctl start tftp.socket
systemctl enable tftp.socket
# Bootloader for BIOS
OS="fedora28"
mkdir /var/lib/tftpboot/

@ -192,8 +192,8 @@ NOTE: Please be patient!
<key name="message_0095">Restarting: [#!variable!daemon!#] after updating the file: [#!variable!file!#].</key>
<key name="message_0096">The file: [#!variable!file!#] did not need to be updated.</key>
<key name="message_0097">The file: [#!variable!file!#] was updated.</key>
<key name="message_0098"></key>
<key name="message_0099"></key>
<key name="message_0098">Enabling and starting: [#!variable!daemon!#]</key>
<key name="message_0099">The daemon: [#!variable!daemon!#] is already enabled, skipping.</key>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>

@ -70,12 +70,12 @@ load_packages($anvil);
# Make sure our repo is installed. If not, install it or fail out.
#check_alteeve_repo($anvil);
# Store the RPMs in repo directory.
#update_install_source($anvil);
# Setup PXE/tftp/dhcpd config.
setup_boot_environment($anvil);
# Store the RPMs in repo directory.
update_install_source($anvil);
# We're done
$anvil->nice_exit({exit_code => 0});
@ -100,7 +100,7 @@ sub setup_boot_environment
if ($anvil->Validate->is_ipv4({ip => $anvil->data->{sys}{network}{interface}{$interface}{ip} }))
{
$bcn_interface = $interface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bcn_interface => $bcn_interface }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bcn_interface => $bcn_interface }});
}
last if $bcn_interface;
}
@ -123,7 +123,7 @@ sub setup_boot_environment
$domain = $anvil->_hostname;
$domain =~ s/^.*?\.//;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
bcn_interface => $bcn_interface,
bcn_ip => $bcn_ip,
bcn_subnet => $bcn_subnet,
@ -142,7 +142,7 @@ sub setup_boot_environment
$third_octet = 254 if $third_octet > 254;
my $first_part = ($bcn_network =~ /^(\d+\.\d+)\./)[0].".".$third_octet;
my $range = $first_part.".10 ".$first_part.".250";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:striker_number' => $striker_number,
's2:third_octet' => $third_octet,
's3:first_part' => $first_part,
@ -157,19 +157,19 @@ sub setup_boot_environment
range => $range,
router => $bcn_ip,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dhcpd_conf_body => $dhcpd_conf_body }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dhcpd_conf_body => $dhcpd_conf_body }});
# Return code if '1' means the file was changed, '2' indicates it didn't change. '0' means something
# went wrong.
my $dhcpd_conf_success = $anvil->Storage->update_file({
body => $dhcpd_conf_body,
file => $anvil->data->{path}{configs}{dhcpd_conf},
file => $anvil->data->{path}{configs}{'dhcpd.conf'},
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dhcpd_conf_success => $dhcpd_conf_success }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dhcpd_conf_success => $dhcpd_conf_success }});
if (not $dhcpd_conf_success)
{
# Failed.
print $anvil->Words->string({key => "error_0043", variables => { file => $anvil->data->{path}{configs}{dhcpd_conf} }})."\n";
print $anvil->Words->string({key => "error_0043", variables => { file => $anvil->data->{path}{configs}{'dhcpd.conf'} }})."\n";
$anvil->nice_exit({code => 3});
}
elsif ($dhcpd_conf_success eq "1")
@ -177,14 +177,14 @@ sub setup_boot_environment
# Restart dhcpd.
print $anvil->Words->string({key => "message_0095", variables => {
daemon => "dhcpd",
file => $anvil->data->{path}{configs}{dhcpd_conf},
file => $anvil->data->{path}{configs}{'dhcpd.conf'},
}})."\n";
$anvil->System->restart_daemon({daemon => "dhcpd"});
$anvil->System->restart_daemon({daemon => $anvil->data->{sys}{daemon}{dhcpd}});
}
elsif ($dhcpd_conf_success eq "2")
{
# Update not needed.
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{dhcpd_conf} }})."\n";
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{'dhcpd.conf'} }})."\n";
}
@ -209,15 +209,150 @@ sub setup_boot_environment
elsif ($dhcpd_conf_success eq "1")
{
# Updated
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{pxe_default} }})."\n";
print $anvil->Words->string({key => "message_0097", variables => { file => $anvil->data->{path}{configs}{pxe_default} }})."\n";
}
elsif ($dhcpd_conf_success eq "2")
{
# Update not needed.
print $anvil->Words->string({key => "message_0097", variables => { file => $anvil->data->{path}{configs}{pxe_default} }})."\n";
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{pxe_default} }})."\n";
}
# Configure apache to show hidden (dot) files.
my $old_autoindex_conf = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'autoindex.conf'}});
my $new_autoindex_conf = "";
my $update_autoindex_conf = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { old_autoindex_conf => $old_autoindex_conf }});
foreach my $line (split/\n/, $old_autoindex_conf)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if (($line =~ /^IndexIgnore /) && ($line =~ / \.\?\?\* /))
{
$line =~ s/ \.\?\?\* / /;
$update_autoindex_conf = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"<< line" => $line,
update_autoindex_conf => $update_autoindex_conf,
}});
}
$new_autoindex_conf .= $line."\n";
}
if ($update_autoindex_conf)
{
# Update and reload apache
$anvil->Storage->backup({debug => 2, file => $anvil->data->{path}{configs}{'autoindex.conf'}});
my $return = $anvil->Storage->write_file({
debug => 2,
body => $new_autoindex_conf,
file => $anvil->data->{path}{configs}{'autoindex.conf'},
overwrite => 1,
mode => "0644",
user => "root",
group => "root"
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'return' => $return }});
if ($return)
{
# Something went wrong.
print $anvil->Words->string({key => "log_0233", variables => { file => $anvil->data->{path}{configs}{'autoindex.conf'}, 'return' => $return }})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0233", variables => { file => $anvil->data->{path}{configs}{'autoindex.conf'}, 'return' => $return }});
$anvil->nice_exit({code => 3});
}
print $anvil->Words->string({key => "message_0095", variables => { daemon => "httpd", file => $anvil->data->{path}{configs}{'autoindex.conf'} }})."\n";
$anvil->System->reloadt_daemon({daemon => $anvil->data->{sys}{daemon}{httpd}});
}
else
{
# Update not needed.
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{'autoindex.conf'} }})."\n";
}
# Update dnf to save downloaded files for later repo building efficiency and to skip upstream repos
# that aren't available at a given time.
my $keepcache_seen = 0;
my $skip_seen = 0;
my $old_dnf_conf = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'dnf.conf'}});
my $new_dnf_conf = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { old_dnf_conf => $old_dnf_conf }});
foreach my $line (split/\n/, $old_dnf_conf)
{
### NOTE: We don't examin the value on purpose. If the user changes these, we'll respect it.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /^keepcache=/)
{
$keepcache_seen = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { keepcache_seen => $keepcache_seen }});
}
elsif ($line =~ /^skip_if_unavailable=/)
{
$skip_seen = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { skip_seen => $skip_seen }});
}
$new_dnf_conf .= $line."\n";
}
die;
if ((not $keepcache_seen) or (not $skip_seen))
{
# Update needed.
if (not $keepcache_seen)
{
$new_dnf_conf .= "keepcache=1\n";
}
if (not $skip_seen)
{
$new_dnf_conf .= "skip_if_unavailable=1\n";
}
$anvil->Storage->backup({debug => 2, file => $anvil->data->{path}{configs}{'dnf.conf'}});
my $return = $anvil->Storage->write_file({
debug => 2,
body => $new_dnf_conf,
file => $anvil->data->{path}{configs}{'dnf.conf'},
overwrite => 1,
mode => "0644",
user => "root",
group => "root"
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'return' => $return }});
if ($return)
{
# Something went wrong.
print $anvil->Words->string({key => "log_0233", variables => { file => $anvil->data->{path}{configs}{'dnf.conf'}, 'return' => $return }})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0233", variables => { file => $anvil->data->{path}{configs}{'dnf.conf'}, 'return' => $return }});
$anvil->nice_exit({code => 3});
}
print $anvil->Words->string({key => "message_0097", variables => { file => $anvil->data->{path}{configs}{'dnf.conf'} }})."\n";
}
else
{
# Update not needed.
print $anvil->Words->string({key => "message_0096", variables => { file => $anvil->data->{path}{configs}{'dnf.conf'} }})."\n";
}
### Check that daemons are enabled/disabled.
### NOTE: We don't manage dhcpd. We leave it off, but if the user enabled it, respect that.
# Make sure tftp is enabled.
if (-e $anvil->data->{path}{systemd}{tftp_enabled_symlink})
{
print $anvil->Words->string({key => "message_0099", variables => { daemon => $anvil->data->{sys}{daemon}{tftp} }})."\n";
}
else
{
print $anvil->Words->string({key => "message_0098", variables => { daemon => $anvil->data->{sys}{daemon}{tftp} }})."\n";
$anvil->System->enable_daemon({daemon => $anvil->data->{sys}{daemon}{tftp}});
$anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{tftp}});
}
if (-e $anvil->data->{path}{systemd}{httpd_enabled_symlink})
{
print $anvil->Words->string({key => "message_0099", variables => { daemon => $anvil->data->{sys}{daemon}{httpd} }})."\n";
}
else
{
print $anvil->Words->string({key => "message_0098", variables => { daemon => $anvil->data->{sys}{daemon}{httpd} }})."\n";
$anvil->System->enable_daemon({daemon => $anvil->data->{sys}{daemon}{httpd}});
$anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{httpd}});
}
return(0);
}

@ -49,9 +49,9 @@ if (not $local_uuid)
if ($local_uuid)
{
# Start checks
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "sys::service::postgresql" => $anvil->data->{sys}{service}{postgresql} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "sys::service::postgresql" => $anvil->data->{sys}{daemon}{postgresql} }});
my $running = $anvil->System->check_daemon({daemon => $anvil->data->{sys}{service}{postgresql}});
my $running = $anvil->System->check_daemon({daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { running => $running }});
if ($running eq "2")
{
@ -191,7 +191,7 @@ if ($local_uuid)
}
# Start the daemon. '0' = started, anything else is a problem.
my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{service}{postgresql}});
my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }});
if ($return_code eq "0")
{
@ -199,7 +199,7 @@ if ($local_uuid)
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0059"});
# Make sure it is enabled on boot.
my $return_code = $anvil->System->enable_daemon({daemon => $anvil->data->{sys}{service}{postgresql}});
my $return_code = $anvil->System->enable_daemon({daemon => $anvil->data->{sys}{daemon}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }});
}
else

Loading…
Cancel
Save