daemon/config: add new rpm-ostreed.conf
Making this a separate commit, since it's a first for rpm-ostree. We now have a conf file complete with man page! No options yet though. Interestingly, there was a function called `rpmostreed_reload_config` which was declared but never defined. Didn't look too much into that. We make sure that the config is part of the things we reload when users call `rpm-ostree reload`. Closes: #1204 Approved by: cgwalters
This commit is contained in:
parent
57eb370eb4
commit
b9bae8fc5b
@ -111,10 +111,13 @@ polkit_policydir = $(datadir)/polkit-1/actions
|
||||
dbus_introspection_DATA = src/daemon/org.projectatomic.rpmostree1.xml
|
||||
dbus_introspectiondir = $(datadir)/dbus-1/interfaces
|
||||
|
||||
sysconf_DATA += $(srcdir)/src/daemon/rpm-ostreed.conf
|
||||
|
||||
EXTRA_DIST += \
|
||||
$(dbus_introspection_DATA) \
|
||||
$(dbusservice_DATA) \
|
||||
$(polkit_policy_DATA) \
|
||||
$(sysconf_DATA) \
|
||||
$(service_in_files) \
|
||||
$(systemdunit_in_files) \
|
||||
$(NULL)
|
||||
|
@ -38,6 +38,7 @@ privlibdir = $(pkglibdir)
|
||||
privlib_LTLIBRARIES =
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA =
|
||||
sysconf_DATA =
|
||||
INTROSPECTION_GIRS =
|
||||
girdir = $(datadir)/gir-1.0
|
||||
gir_DATA =
|
||||
|
@ -16,6 +16,7 @@
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
man1_MANS = rpm-ostree.1
|
||||
man5_MANS = rpm-ostreed.conf.5
|
||||
|
||||
XSLTPROC_FLAGS = \
|
||||
--nonet \
|
||||
@ -31,4 +32,7 @@ XSLTPROC_FLAGS_MAN = \
|
||||
rpm-ostree.1: man/rpm-ostree.xml Makefile
|
||||
$(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS_MAN) $<
|
||||
|
||||
CLEANFILES += rpm-ostree.1
|
||||
rpm-ostreed.conf.5: man/rpm-ostreed.conf.xml Makefile
|
||||
$(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS_MAN) $<
|
||||
|
||||
CLEANFILES += $(man1_MANS) $(man5_MANS)
|
||||
|
@ -38,7 +38,8 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' \
|
||||
-DWITH_SWDB=0 \
|
||||
-DLIBEXECDIR='"$(libexecdir)"' \
|
||||
-DLOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \
|
||||
-DSYSCONFDIR='"$(sysconfdir)"' \
|
||||
-DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \
|
||||
-DRPM_OSTREE_GITREV='"$(RPM_OSTREE_GITREV)"' \
|
||||
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_50 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_50
|
||||
# Keep this in sync with the AM_CFLAGS in libostree; see
|
||||
|
92
man/rpm-ostreed.conf.xml
Normal file
92
man/rpm-ostreed.conf.xml
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version='1.0'?> <!--*-nxml-*-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (C) 2018 Red Hat, Inc.
|
||||
|
||||
This library 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.
|
||||
|
||||
This library 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 this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
-->
|
||||
|
||||
<refentry id="rpm-ostreed.conf">
|
||||
|
||||
<refentryinfo>
|
||||
<title>rpm-ostreed.conf</title>
|
||||
<productname>rpm-ostree</productname>
|
||||
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Jonathan</firstname>
|
||||
<surname>Lebon</surname>
|
||||
<email>jlebon@redhat.com</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>rpm-ostreed.conf</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>rpm-ostreed.conf</refname>
|
||||
<refpurpose>RPM-OSTree daemon configuration file</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<para><filename>/etc/rpm-ostreed.conf</filename></para>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
This file configures the RPM-OSTree daemon.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<para>
|
||||
All options are configured in the "[Daemon]" section. There are
|
||||
currently no available options.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
<!--
|
||||
<varlistentry>
|
||||
<term><varname>OptionName=</varname></term>
|
||||
|
||||
<listitem>
|
||||
<para>Template for adding option names. Values are enumerated like "val1",
|
||||
"val2".</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
-->
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
|
||||
<para>
|
||||
<citerefentry><refentrytitle>rpm-ostree</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
5
src/daemon/rpm-ostreed.conf
Normal file
5
src/daemon/rpm-ostreed.conf
Normal file
@ -0,0 +1,5 @@
|
||||
# Entries in this file show the compile time defaults.
|
||||
# You can change settings by editing this file.
|
||||
# For option meanings, see rpm-ostreed.conf(5).
|
||||
|
||||
[Daemon]
|
@ -34,6 +34,9 @@
|
||||
* follow-up requests are more responsive */
|
||||
#define IDLE_EXIT_TIMEOUT_SECONDS 60
|
||||
|
||||
#define RPMOSTREED_CONF SYSCONFDIR "/rpm-ostreed.conf"
|
||||
#define DAEMON_CONFIG_GROUP "Daemon"
|
||||
|
||||
/**
|
||||
* SECTION: daemon
|
||||
* @title: RpmostreedDaemon
|
||||
@ -246,6 +249,10 @@ rpmostreed_daemon_initable_init (GInitable *initable,
|
||||
g_dbus_object_manager_server_set_connection (self->object_manager, self->connection);
|
||||
g_debug ("exported object manager");
|
||||
|
||||
/* do this early so sysroot startup sets properties to the right values */
|
||||
if (!rpmostreed_daemon_reload_config (self, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
g_autofree gchar *path =
|
||||
rpmostreed_generate_object_path (BASE_DBUS_PATH, "Sysroot", NULL);
|
||||
self->sysroot = g_object_new (RPMOSTREED_TYPE_SYSROOT,
|
||||
@ -279,6 +286,49 @@ rpmostreed_daemon_initable_init (GInitable *initable,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Returns TRUE if config file exists and could be loaded or if config file doesn't exist.
|
||||
* Returns FALSE if config file exists but could not be loaded. */
|
||||
static gboolean
|
||||
maybe_load_config_keyfile (GKeyFile **out_keyfile,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
|
||||
g_autoptr(GKeyFile) keyfile = g_key_file_new ();
|
||||
if (g_key_file_load_from_file (keyfile, RPMOSTREED_CONF, 0, &local_error))
|
||||
{
|
||||
*out_keyfile = g_steal_pointer (&keyfile);
|
||||
sd_journal_print (LOG_INFO, "Reading config file '%s'", RPMOSTREED_CONF);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!g_error_matches (local_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||
{
|
||||
g_propagate_error (error, g_steal_pointer (&local_error));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sd_journal_print (LOG_WARNING, "Missing config file '%s'; using compiled defaults",
|
||||
RPMOSTREED_CONF);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
rpmostreed_daemon_reload_config (RpmostreedDaemon *self,
|
||||
gboolean *out_changed,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
if (!maybe_load_config_keyfile (&config, error))
|
||||
return FALSE;
|
||||
|
||||
/* when we have configs, we'll read them in here */
|
||||
|
||||
if (out_changed)
|
||||
*out_changed = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
rpmostreed_daemon_class_init (RpmostreedDaemonClass *klass)
|
||||
{
|
||||
|
@ -47,5 +47,6 @@ void rpmostreed_daemon_publish (RpmostreedDaemon *self,
|
||||
void rpmostreed_daemon_unpublish (RpmostreedDaemon *self,
|
||||
const gchar *path,
|
||||
gpointer thing);
|
||||
gboolean rpmostreed_reload_config (RpmostreedDaemon *self,
|
||||
gboolean rpmostreed_daemon_reload_config (RpmostreedDaemon *self,
|
||||
gboolean *out_changed,
|
||||
GError **error);
|
||||
|
@ -417,6 +417,9 @@ handle_reload_config (RPMOSTreeSysroot *object,
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
GError **error = &local_error;
|
||||
|
||||
if (!rpmostreed_daemon_reload_config (rpmostreed_daemon_get (), NULL, error))
|
||||
goto out;
|
||||
|
||||
if (!rpmostreed_sysroot_reload (self, error))
|
||||
goto out;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user