Libvirt: Add backup
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 2 Aug 2016 12:01:05 +0000 (14:01 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 2 Aug 2016 15:07:33 +0000 (16:07 +0100)
The directory /etc/libvirt is backed up on uninstallation  and is
restored on installation.

Alle Files in  /var are commented in the rootfile so they are not
removed on uninstallation.
Because of the fact that the directories are not shipped with the
package they were created at installation time.
The permissions of 3 directories are changed because the qemu user is
nobody and the qemu group is kvm, so the permissions must be nobody:kvm

Fixes: #11151

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/backup/includes/libvirt [new file with mode: 0644]
config/rootfiles/packages/libvirt
lfs/libvirt
src/paks/libvirt/install.sh
src/paks/libvirt/uninstall.sh

diff --git a/config/backup/includes/libvirt b/config/backup/includes/libvirt
new file mode 100644 (file)
index 0000000..2306999
--- /dev/null
@@ -0,0 +1 @@
+/etc/libvirt
index aa20aaa..b193987 100644 (file)
@@ -271,17 +271,18 @@ usr/share/libvirt/schemas/storagevol.rng
 #usr/share/man/man8/libvirtd.8
 #usr/share/man/man8/virtlockd.8
 #var/cache/libvirt
-var/cache/libvirt/qemu
+#var/cache/libvirt/qemu
 #var/lib/libvirt
-var/lib/libvirt/boot
-var/lib/libvirt/filesystems
-var/lib/libvirt/images
+#var/lib/libvirt/boot
+#var/lib/libvirt/filesystems
+#var/lib/libvirt/images
 #var/lib/libvirt/lockd
-var/lib/libvirt/lockd/files
-var/lib/libvirt/qemu
+#var/lib/libvirt/lockd/files
+#var/lib/libvirt/qemu
 #var/log/libvirt
 #var/log/libvirt/lxc
-var/log/libvirt/qemu
+#var/log/libvirt/qemu
 #var/log/libvirt/uml
 etc/rc.d/init.d/libvirt-guests
 etc/rc.d/init.d/libvirtd
+var/ipfire/backup/addons/includes/libvirt
index 6768a72..c551bc2 100644 (file)
@@ -33,7 +33,7 @@ DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 SUP_ARCH   = i586 x86_64
 PROG       = libvirt
-PAK_VER    = 4
+PAK_VER    = 5
 
 DEPS       = "libpciaccess libyajl ncat qemu"
 
@@ -91,5 +91,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        cd $(DIR_APP) && make install
        install -v -m 754 $(DIR_SRC)/src/initscripts/init.d/libvirtd /etc/rc.d/init.d/libvirtd
        mv /usr/libexec/libvirt-guests.sh /etc/rc.d/init.d/libvirt-guests
+       # Backup
+       install -v -m 644 $(DIR_SRC)/config/backup/includes/libvirt /var/ipfire/backup/addons/includes/libvirt
        @rm -rf $(DIR_APP)
        @$(POSTBUILD)
index c97a18d..1034b6b 100644 (file)
@@ -29,6 +29,22 @@ getent passwd libvirt-remote >/dev/null || \
 useradd -m -g libvirt-remote -s /bin/bash "libvirt-remote"
 
 extract_files
+
+# create diretorys in var
+mkdir -p /var/cache/libvirt/qemu \
+/var/lib/libvirt/boot \
+/var/lib/libvirt/filesystems \
+/var/lib/libvirt/images \
+/var/lib/libvirt/lockd/files \
+/var/lib/libvirt/qemu \
+/var/log/libvirt/qemu
+# set the permissions
+chown -R nobody:kvm /var/cache/libvirt/qemu
+chown -R nobody:kvm /var/lib/libvirt/qemu
+chown -R nobody:kvm /var/lib/libvirt/images
+# restore the backup
+restore_backup ${NAME}
+
 start_service --delay 300 --background libvirtd
 ln -svf /etc/init.d/libvirtd /etc/rc.d/rc0.d/K20libvirtd
 ln -svf /etc/init.d/libvirtd /etc/rc.d/rc3.d/S70libvirtd
index 16dc724..23c86e5 100644 (file)
 #
 . /opt/pakfire/lib/functions.sh
 stop_service libvirtd
+
+extract_backup_includes
+make_backup ${NAME}
+
 remove_files
 
 rm -f /etc/rc.d/rc*.d/*libvirt-guests