Skip to content
Permalink
Browse files

make install script idempotent

create done file /var/lib/whonix-libvirt/install.done

run install script when done file does not exist

https://forums.whonix.org/t/whonix-desktop-installer-with-calamares-field-report/7350/15?u=patrick
  • Loading branch information...
adrelanos committed May 12, 2019
1 parent c19243a commit 062a399bcd156bb0dccec17fad0602e68c5086fc
Showing with 60 additions and 10 deletions.
  1. +47 −0 debian/whonix-libvirt.postinst
  2. +13 −10 usr/lib/whonix-libvirt/install
@@ -0,0 +1,47 @@
#!/bin/bash

## Copyright (C) 2019 - 2019 ENCRYPTED SUPPORT LP <adrelanos@riseup.net>
## See the file COPYING for copying conditions.

if [ -f /usr/lib/helper-scripts/pre.bsh ]; then
source /usr/lib/helper-scripts/pre.bsh
fi

set -e

true "
#####################################################################
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

case "$1" in
configure)
if [ ! -f "/var/lib/whonix-libvirt/install.done" ]; then
/usr/lib/whonix-libvirt/install
fi
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "$DPKG_MAINTSCRIPT_NAME called with unknown argument \`$1'" >&2
exit 1
;;
esac

true "INFO: debhelper beginning here."

#DEBHELPER#

true "INFO: Done with debhelper."

true "
#####################################################################
## INFO: END : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Explicitly "exit 0", so eventually trapped errors can be ignored.
exit 0
@@ -28,18 +28,21 @@ else
systemctl --no-pager start libvirtd
fi

virsh -c qemu:///system net-autostart "default"
virsh -c qemu:///system net-start "default"
virsh -c qemu:///system net-define "/usr/share/whonix-libvirt/xml/Whonix-External.xml"
virsh -c qemu:///system net-define "/usr/share/whonix-libvirt/xml/Whonix-Internal.xml"
virsh -c qemu:///system net-autostart "Whonix-External"
virsh -c qemu:///system net-start "Whonix-External"
virsh -c qemu:///system net-autostart "Whonix-Internal"
virsh -c qemu:///system net-start "Whonix-Internal"
virsh -c qemu:///system define "$temp_dir/xml/Whonix-Gateway.xml"
virsh -c qemu:///system define "$temp_dir/xml/Whonix-Workstation.xml"
virsh -c qemu:///system net-autostart "default" || true
virsh -c qemu:///system net-start "default" || true
virsh -c qemu:///system net-define "/usr/share/whonix-libvirt/xml/Whonix-External.xml" || true
virsh -c qemu:///system net-define "/usr/share/whonix-libvirt/xml/Whonix-Internal.xml" || true
virsh -c qemu:///system net-autostart "Whonix-External" || true
virsh -c qemu:///system net-start "Whonix-External" || true
virsh -c qemu:///system net-autostart "Whonix-Internal" || true
virsh -c qemu:///system net-start "Whonix-Internal" || true
virsh -c qemu:///system define "$temp_dir/xml/Whonix-Gateway.xml" || true
virsh -c qemu:///system define "$temp_dir/xml/Whonix-Workstation.xml" || true

if [ "$stop_libvirtd" = "true" ]; then
true "libvirtd was not running before running this script, so stopping it now."
systemctl --no-pager stop libvirtd
fi

mkdir --parents /var/lib/whonix-libvirt
touch /var/lib/whonix-libvirt/install.done

0 comments on commit 062a399

Please sign in to comment.
You can’t perform that action at this time.