]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
extended generic plugin support for rollback 730/head
authorArvin Schnell <aschnell@suse.de>
Tue, 7 Jun 2022 09:13:51 +0000 (11:13 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 7 Jun 2022 09:14:49 +0000 (11:14 +0200)
client/cmd-rollback.cc
doc/snapper.xml.in
scripts/10-plugin-test.sh [new file with mode: 0755]
snapper/Hooks.cc
snapper/Hooks.h

index 0533075dd1f6e22df4addebf1284d93384e6b809..2bf41c34f12acb472459217715e17f585781f5c1 100644 (file)
@@ -247,6 +247,7 @@ namespace snapper
 
                Hooks::rollback(filesystem->snapshotDir(snapshot1->getNum()),
                                filesystem->snapshotDir(snapshot2->getNum()));
+               Hooks::rollback(subvolume, filesystem, snapshot1->getNum(), snapshot2->getNum());
 
                if (print_number)
                    cout << snapshot2->getNum() << endl;
@@ -291,6 +292,7 @@ namespace snapper
 
                Hooks::rollback(filesystem->snapshotDir(previous_default->getNum()),
                                filesystem->snapshotDir(snapshot->getNum()));
+               Hooks::rollback(subvolume, filesystem, previous_default->getNum(), snapshot->getNum());
            }
            break;
 
index 8f567f18b6d02edaa0473f1eda0f8a2e7847b254..5d79eccbdccd5e0ff2f818a064feb400939ad628 100644 (file)
          <para>Executed when the default snapshot gets changed</para>
        </listitem>
       </varlistentry>
+      <varlistentry>
+       <term><option>rollback <replaceable>subvolume</replaceable> <replaceable>fstype</replaceable> <replaceable>old-snapshot-number</replaceable> <replaceable>new-snapshot-number</replaceable></option></term>
+       <listitem>
+         <para>Executed when a rollback is done</para>
+       </listitem>
+      </varlistentry>
     </variablelist>
-    <para>More arguments may be passed in the future. Using snapper in
+    <para>More actions and arguments can be added any time. Using snapper in
     the plugins is not allowed.</para>
   </refsect1>
 
diff --git a/scripts/10-plugin-test.sh b/scripts/10-plugin-test.sh
new file mode 100755 (executable)
index 0000000..9de0a0c
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Use only for testing.
+
+echo `date +"%F %T"` $* >> /tmp/snapper-plugin-test.log
+
index b4924dba937aa0a22835d58de2e0e821d7ff30cc..3acf160a12980a1cff39f2b3285900a9db4da33a 100644 (file)
@@ -143,4 +143,11 @@ namespace snapper
 #endif
     }
 
+
+    void
+    Hooks::rollback(const string& subvolume, const Filesystem* filesystem, unsigned int old_num, unsigned int new_num)
+    {
+       run_scripts({ "rollback", subvolume, filesystem->fstype(), std::to_string(old_num), std::to_string(new_num) });
+    }
+
 }
index 3b31857de3fe13e7b6db002a852d25f9dcfd1a29..97a96ef17b370e3d4e73f9170187c00b142a3af2 100644 (file)
@@ -48,6 +48,7 @@ namespace snapper
        static void set_default_snapshot(const string& subvolume, const Filesystem* filesystem, unsigned int num);
 
        static void rollback(const string& old_root, const string& new_root);
+       static void rollback(const string& subvolume, const Filesystem* filesystem, unsigned int old_num, unsigned int new_num);
 
     private: