summaryrefslogtreecommitdiff
path: root/src/dbus-manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-13 20:20:36 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-13 20:20:36 +0200
commit6f28c033ec506847b3bfa4efaf52478120c36946 (patch)
tree3300ac0aa44cb74ae1e38a298c0ed09527f7f522 /src/dbus-manager.c
parent3dda9fc3a738241e42df43dbebf9e479e5ad1da8 (diff)
systemctl: introduce try-restart and reload-or-restart commands
Diffstat (limited to 'src/dbus-manager.c')
-rw-r--r--src/dbus-manager.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index f52b06e5fb..c717ccd81f 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -62,6 +62,16 @@
" <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
" </method>\n" \
+ " <method name=\"ReloadOrRestartUnit\">\n" \
+ " <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
+ " </method>\n" \
+ " <method name=\"ReloadOrTryRestartUnit\">\n" \
+ " <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
+ " </method>\n" \
" <method name=\"GetJob\">\n" \
" <arg name=\"id\" type=\"u\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
@@ -239,6 +249,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
DBusMessage *reply = NULL;
char * path = NULL;
JobType job_type = _JOB_TYPE_INVALID;
+ bool reload_if_possible = false;
assert(connection);
assert(message);
@@ -310,7 +321,13 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
job_type = JOB_RESTART;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "TryRestartUnit"))
job_type = JOB_TRY_RESTART;
- else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
+ else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ReloadOrRestartUnit")) {
+ reload_if_possible = true;
+ job_type = JOB_RESTART;
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ReloadOrTryRestartUnit")) {
+ reload_if_possible = true;
+ job_type = JOB_TRY_RESTART;
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
uint32_t id;
Job *j;
@@ -739,6 +756,13 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
if ((r = manager_load_unit(m, name, NULL, &error, &u)) < 0)
return bus_send_error_reply(m, connection, message, &error, r);
+ if (reload_if_possible && unit_can_reload(u)) {
+ if (job_type == JOB_RESTART)
+ job_type = JOB_RELOAD_OR_START;
+ else if (job_type == JOB_TRY_RESTART)
+ job_type = JOB_RELOAD;
+ }
+
if (job_type == JOB_START && u->meta.only_by_dependency) {
dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Unit may be activated by dependency only.");
return bus_send_error_reply(m, connection, message, &error, -EPERM);