From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH] Libvirt: Add backup
Date: Tue, 02 Aug 2016 14:01:05 +0200 [thread overview]
Message-ID: <1470139265-9999-1-git-send-email-jonatan.schlag@ipfire.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 4106 bytes --]
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(a)ipfire.org>
---
config/backup/includes/libvirt | 1 +
config/rootfiles/packages/libvirt | 15 ++++++++-------
lfs/libvirt | 4 +++-
src/paks/libvirt/install.sh | 16 ++++++++++++++++
src/paks/libvirt/uninstall.sh | 4 ++++
5 files changed, 32 insertions(+), 8 deletions(-)
create mode 100644 config/backup/includes/libvirt
diff --git a/config/backup/includes/libvirt b/config/backup/includes/libvirt
new file mode 100644
index 0000000..2306999
--- /dev/null
+++ b/config/backup/includes/libvirt
@@ -0,0 +1 @@
+/etc/libvirt
diff --git a/config/rootfiles/packages/libvirt b/config/rootfiles/packages/libvirt
index aa20aaa..b193987 100644
--- a/config/rootfiles/packages/libvirt
+++ b/config/rootfiles/packages/libvirt
@@ -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
diff --git a/lfs/libvirt b/lfs/libvirt
index 6768a72..c551bc2 100644
--- a/lfs/libvirt
+++ b/lfs/libvirt
@@ -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)
diff --git a/src/paks/libvirt/install.sh b/src/paks/libvirt/install.sh
index c97a18d..1034b6b 100644
--- a/src/paks/libvirt/install.sh
+++ b/src/paks/libvirt/install.sh
@@ -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
diff --git a/src/paks/libvirt/uninstall.sh b/src/paks/libvirt/uninstall.sh
index 16dc724..23c86e5 100644
--- a/src/paks/libvirt/uninstall.sh
+++ b/src/paks/libvirt/uninstall.sh
@@ -23,6 +23,10 @@
#
. /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
--
2.1.4
next reply other threads:[~2016-08-02 12:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-02 12:01 Jonatan Schlag [this message]
2016-08-02 13:12 ` Michael Tremer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470139265-9999-1-git-send-email-jonatan.schlag@ipfire.org \
--to=jonatan.schlag@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox