+-------------------------------------------------------------------
+Fri Jul 14 14:05:56 CEST 2023 - aschnell@suse.com
+
+- enable snapper-timeline.timer when adjusting config using
+ snapper (gh#openSUSE/snapper#788)
+
-------------------------------------------------------------------
Wed Jul 12 09:03:42 CEST 2023 - aschnell@suse.com
AsciiFile.cc AsciiFile.h \
Acls.cc Acls.h \
Hooks.cc Hooks.h \
+ Systemctl.cc Systemctl.h \
Exception.cc Exception.h \
SnapperTmpl.h \
SnapperTypes.h \
#include "snapper/Exception.h"
#include "snapper/Hooks.h"
#include "snapper/ComparisonImpl.h"
+#include "snapper/Systemctl.h"
#ifdef ENABLE_BTRFS
#include "snapper/Btrfs.h"
#include "snapper/BtrfsUtils.h"
{
y2mil("Snapper constructor");
y2mil("libsnapper version " VERSION);
- y2mil("config_name:" << config_name << " disable_filters:" << disable_filters);
+ y2mil("config_name:" << config_name << " root_prefix:" << root_prefix <<
+ " disable_filters:" << disable_filters);
try
{
#endif
bool sync_acl;
- if (config_info->get_value(KEY_SYNC_ACL, sync_acl) && sync_acl == true)
+ if (config_info->get_value(KEY_SYNC_ACL, sync_acl) && sync_acl)
syncAcl();
y2mil("subvolume:" << config_info->get_subvolume() << " filesystem:" <<
SN_THROW(CreateConfigFailedException(e.what()));
}
+ bool timeline_create = false;
+
try
{
SysconfigFile config(template_file);
config.set_value(KEY_FSTYPE, filesystem->fstype());
config.save();
+
+ config.get_value(KEY_TIMELINE_CREATE, timeline_create);
}
catch (const Exception& e)
{
SN_RETHROW(e);
}
+ if (timeline_create)
+ {
+ systemctl_enable_timeline(true);
+ }
+
Hooks::create_config(Hooks::Stage::POST_ACTION, subvolume, filesystem.get());
}
SN_THROW(DeleteConfigFailedException("modifying sysconfig-file failed"));
}
+ // TODO potentially disable snapper-timeline.timer
+
Hooks::delete_config(Hooks::Stage::POST_ACTION, snapper->subvolumeDir(), snapper->getFilesystem());
}
raw.find(KEY_SYNC_ACL) != raw.end())
{
bool sync_acl;
- if (config_info->get_value(KEY_SYNC_ACL, sync_acl) && sync_acl == true)
+ if (config_info->get_value(KEY_SYNC_ACL, sync_acl) && sync_acl)
syncAcl();
}
+
+ if (raw.find(KEY_TIMELINE_CREATE) != raw.end())
+ {
+ bool timeline_create;
+ if (config_info->get_value(KEY_TIMELINE_CREATE, timeline_create))
+ {
+ if (timeline_create)
+ {
+ systemctl_enable_timeline(true);
+ }
+ else
+ {
+ // TODO potentially disable snapper-timeline.timer
+ }
+ }
+ }
}
void syncInfoDir(SDir& dir) const;
+ // const std::string root_prefix; // TODO ABI change
+
ConfigInfo* config_info = nullptr;
Filesystem* filesystem = nullptr;
/*
* Copyright (c) [2004-2014] Novell, Inc.
- * Copyright (c) [2020-2022] SUSE LLC
+ * Copyright (c) [2020-2023] SUSE LLC
*
* All Rights Reserved.
*
#define SH_BIN "/bin/sh"
+#define SYSTEMCTL_BIN "/usr/bin/systemctl"
+
// keys from the config files
#define KEY_ALLOW_GROUPS "ALLOW_GROUPS"
#define KEY_SYNC_ACL "SYNC_ACL"
#define KEY_COMPRESSION "COMPRESSION"
+#define KEY_TIMELINE_CREATE "TIMELINE_CREATE"
#endif
--- /dev/null
+/*
+ * Copyright (c) 2023 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program 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 General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "snapper/SystemCmd.h"
+#include "snapper/SnapperDefines.h"
+
+
+namespace snapper
+{
+
+ void
+ systemctl_enable_unit(bool enable, bool now, const string& name)
+ {
+ // When run in a chroot system the enable command works but the start command
+ // fails (which is likely what we want).
+
+ SystemCmd cmd(SYSTEMCTL_BIN " " + string(enable ? "enable " : "disable ") +
+ string(now ? "--now " : "") + name);
+ }
+
+
+ void
+ systemctl_enable_timeline(bool enable, bool now)
+ {
+ systemctl_enable_unit(enable, now, "snapper-timeline.timer");
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program 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 General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+namespace snapper
+{
+
+ void systemctl_enable_timeline(bool enable, bool now = true);
+
+}