mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 18:50:07 +01:00
Cloud setups often have a never-changing setup and since every cycle counts, they don't really want a management process running in the background after network setup is complete. Since it's likely a VM, it's not like links are going to go up/down very often. Add a new "configure-quit=true/false" config option which, when set to true, will quit NetworkManager after startup and initial configuration is complete.
This commit is contained in:
parent
7df18cba5b
commit
a01e2ff91d
3 changed files with 30 additions and 0 deletions
19
src/main.c
19
src/main.c
|
|
@ -177,6 +177,20 @@ _init_nm_debug (const char *debug)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
manager_startup_complete (NMManager *manager, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMConfig *config = NM_CONFIG (user_data);
|
||||
gboolean startup = FALSE;
|
||||
|
||||
g_object_get (G_OBJECT (manager), NM_MANAGER_STARTUP, &startup, NULL);
|
||||
|
||||
if (!startup && nm_config_get_configure_and_quit (config)) {
|
||||
nm_log_info (LOGD_CORE, "quitting now that startup is complete");
|
||||
g_main_loop_quit (main_loop);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* main
|
||||
*
|
||||
|
|
@ -448,6 +462,11 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
g_signal_connect (manager,
|
||||
"notify::" NM_MANAGER_STARTUP,
|
||||
G_CALLBACK (manager_startup_complete),
|
||||
config);
|
||||
|
||||
nm_manager_start (manager);
|
||||
|
||||
/* Make sure the loopback interface is up. If interface is down, we bring
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ typedef struct {
|
|||
|
||||
char **no_auto_default;
|
||||
char **ignore_carrier;
|
||||
|
||||
gboolean configure_and_quit;
|
||||
} NMConfigPrivate;
|
||||
|
||||
static NMConfig *singleton = NULL;
|
||||
|
|
@ -218,6 +220,12 @@ nm_config_get_connectivity_response (NMConfig *config)
|
|||
return NM_CONFIG_GET_PRIVATE (config)->connectivity_response;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_config_get_configure_and_quit (NMConfig *config)
|
||||
{
|
||||
return NM_CONFIG_GET_PRIVATE (config)->configure_and_quit;
|
||||
}
|
||||
|
||||
char *
|
||||
nm_config_get_value (NMConfig *config, const char *group, const char *key, GError **error)
|
||||
{
|
||||
|
|
@ -623,6 +631,8 @@ nm_config_new (GError **error)
|
|||
|
||||
priv->ignore_carrier = g_key_file_get_string_list (priv->keyfile, "main", "ignore-carrier", NULL, NULL);
|
||||
|
||||
priv->configure_and_quit = g_key_file_get_boolean (priv->keyfile, "main", "configure-and-quit", NULL);
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ const char *nm_config_get_debug (NMConfig *config);
|
|||
const char *nm_config_get_connectivity_uri (NMConfig *config);
|
||||
guint nm_config_get_connectivity_interval (NMConfig *config);
|
||||
const char *nm_config_get_connectivity_response (NMConfig *config);
|
||||
gboolean nm_config_get_configure_and_quit (NMConfig *config);
|
||||
|
||||
gboolean nm_config_get_ethernet_can_auto_default (NMConfig *config, NMDevice *device);
|
||||
void nm_config_set_ethernet_no_auto_default (NMConfig *config, NMDevice *device);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue