mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
bin/admin: Check for booted deployment to see if we should reboot
Rather than calling `ostree_sysroot_get_path()`, which I'd like to deprecate for the same reason as `ostree_repo_get_path()`. Closes: #1123 Approved by: jlebon
This commit is contained in:
parent
b71fdbcb5c
commit
aef5a7331e
@ -151,13 +151,15 @@ ot_admin_sysroot_lock (OstreeSysroot *sysroot,
|
||||
gboolean
|
||||
ot_admin_execve_reboot (OstreeSysroot *sysroot, GError **error)
|
||||
{
|
||||
g_autoptr(GFile) real_sysroot = g_file_new_for_path ("/");
|
||||
OstreeDeployment *booted = ostree_sysroot_get_booted_deployment (sysroot);
|
||||
|
||||
if (g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot))
|
||||
{
|
||||
if (execlp ("systemctl", "systemctl", "reboot", NULL) < 0)
|
||||
return glnx_throw_errno (error);
|
||||
}
|
||||
/* If the sysroot isn't booted, we shouldn't reboot, even if somehow the user
|
||||
* asked for it; might accidentally be specified in a build script, etc.
|
||||
*/
|
||||
if (!booted)
|
||||
return TRUE;
|
||||
|
||||
if (execlp ("systemctl", "systemctl", "reboot", NULL) < 0)
|
||||
return glnx_throw_errno_prefix (error, "execve(systemctl reboot)");
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user