1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
// Copyright Contributors to the DNF5 project.
// Copyright (C) 2022 Red Hat, Inc.
// SPDX-License-Identifier: LGPL-2.0-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/dnf5/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#ifndef DNF5_PLUGINS_AUTOMATIC_PLUGIN_CONFIG_AUTOMATIC_HPP
#define DNF5_PLUGINS_AUTOMATIC_PLUGIN_CONFIG_AUTOMATIC_HPP
#include "libdnf5/conf/config.hpp"
#include "libdnf5/conf/option_bool.hpp"
#include "libdnf5/conf/option_enum.hpp"
#include "libdnf5/conf/option_number.hpp"
#include "libdnf5/conf/option_string.hpp"
#include "libdnf5/conf/option_string_list.hpp"
#include <map>
#include <string>
#include <vector>
namespace dnf5 {
// options in [commands] section
class ConfigAutomaticCommands : public libdnf5::Config {
public:
ConfigAutomaticCommands();
~ConfigAutomaticCommands() = default;
libdnf5::OptionEnum upgrade_type{"default", {"default", "security"}};
libdnf5::OptionNumber<std::uint32_t> random_sleep{0};
libdnf5::OptionNumber<std::int32_t> network_online_timeout{60};
libdnf5::OptionBool download_updates{true};
libdnf5::OptionBool apply_updates{false};
libdnf5::OptionEnum reboot{"never", {"never", "when-changed", "when-needed"}};
libdnf5::OptionString reboot_command{"shutdown -r +5 'Rebooting after applying package updates'"};
};
// options in [emitters] section
class ConfigAutomaticEmitters : public libdnf5::Config {
public:
ConfigAutomaticEmitters();
~ConfigAutomaticEmitters() = default;
libdnf5::OptionStringList emit_via{std::vector<std::string>{"stdio"}};
libdnf5::OptionString system_name{gethostname()};
libdnf5::OptionBool emit_no_updates{false};
private:
static std::string gethostname();
};
// options in [email] section
class ConfigAutomaticEmail : public libdnf5::Config {
public:
ConfigAutomaticEmail();
~ConfigAutomaticEmail() = default;
libdnf5::OptionStringList email_to{std::vector<std::string>{"root"}};
libdnf5::OptionString email_from{"root"};
libdnf5::OptionString email_host{"localhost"};
libdnf5::OptionNumber<std::int32_t> email_port{25};
libdnf5::OptionEnum email_tls{"no", {"no", "yes", "starttls"}};
};
// options in [command] section
class ConfigAutomaticCommand : public libdnf5::Config {
public:
ConfigAutomaticCommand();
~ConfigAutomaticCommand() = default;
libdnf5::OptionString command_format{"cat"};
libdnf5::OptionString stdin_format{"{body}"};
};
// options in [command_email] section
class ConfigAutomaticCommandEmail : public libdnf5::Config {
public:
ConfigAutomaticCommandEmail();
~ConfigAutomaticCommandEmail() = default;
libdnf5::OptionString command_format{"mail -Ssendwait -s {subject} -r {email_from} {email_to}"};
libdnf5::OptionString stdin_format{"{body}"};
libdnf5::OptionStringList email_to{std::vector<std::string>{"root"}};
libdnf5::OptionString email_from{"root"};
};
class ConfigAutomatic {
public:
ConfigAutomatic() {};
~ConfigAutomatic() = default;
void load_from_parser(
const libdnf5::ConfigParser & parser,
const libdnf5::Vars & vars,
libdnf5::Logger & logger,
libdnf5::Option::Priority priority = libdnf5::Option::Priority::AUTOMATICCONFIG);
ConfigAutomaticCommands config_commands;
ConfigAutomaticEmitters config_emitters;
ConfigAutomaticEmail config_email;
ConfigAutomaticCommand config_command;
ConfigAutomaticCommandEmail config_command_email;
};
} // namespace dnf5
#endif
|