Skip to content

Commit

Permalink
Merge pull request #54 from plundstr/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
Pekka Lundstrom committed Feb 3, 2014
2 parents f2fe58d + 29f8270 commit dcabec7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,5 +1,5 @@
# Package name and version
AC_INIT(dsme, 0.64.6)
AC_INIT(dsme, 0.65.0)

AM_INIT_AUTOMAKE

Expand Down
21 changes: 19 additions & 2 deletions modules/runlevel.c
Expand Up @@ -80,6 +80,8 @@ static bool change_runlevel(dsme_runlevel_t runlevel)
*/
static void shutdown(dsme_runlevel_t runlevel)
{
char command[64];

if ((runlevel != DSME_RUNLEVEL_REBOOT) &&
(runlevel != DSME_RUNLEVEL_SHUTDOWN) &&
(runlevel != DSME_RUNLEVEL_MALF))
Expand All @@ -92,10 +94,25 @@ static void shutdown(dsme_runlevel_t runlevel)
runlevel == DSME_RUNLEVEL_REBOOT ? "Reboot" :
"Malf");

/* If we have systemd, use systemctl commands */
if (access("/bin/systemctl", X_OK) == 0) {
if (runlevel == DSME_RUNLEVEL_SHUTDOWN) {
snprintf(command, sizeof(command), "/bin/systemctl --no-block poweroff");
} else if (runlevel == DSME_RUNLEVEL_REBOOT) {
snprintf(command, sizeof(command), "/bin/systemctl --no-block reboot");
} else {
dsme_log(LOG_WARNING, "MALF not supported by our systemd implementation");
goto fail_and_exit;
}
dsme_log(LOG_NOTICE, "Issuing %s", command);
if (system(command) != 0) {
dsme_log(LOG_WARNING, "command %s failed: %m", command);
/* We ignore error. No retry or anything else */
}
}
/* If runlevel change fails, handle the shutdown/reboot by DSME */
if (!change_runlevel(runlevel))
else if (!change_runlevel(runlevel))
{
char command[32];
dsme_log(LOG_CRIT, "Doing forced shutdown/reboot");
sync();

Expand Down
2 changes: 1 addition & 1 deletion rpm/dsme.spec
Expand Up @@ -13,7 +13,7 @@ Name: dsme
# << macros

Summary: Device State Management Entity
Version: 0.64.6
Version: 0.65.0
Release: 0
Group: System/System Control
License: LGPLv2+
Expand Down
2 changes: 1 addition & 1 deletion rpm/dsme.yaml
@@ -1,6 +1,6 @@
Name: dsme
Summary: Device State Management Entity
Version: 0.64.6
Version: 0.65.0
Release: 0
Group: System/System Control
License: LGPLv2+
Expand Down

0 comments on commit dcabec7

Please sign in to comment.