Skip to content

A hardened Linux desktop, rebuilt from scratch, with your Windows apps built in. Free and open source.

2.0 KB
Raw Blame
#!/bin/sh
set -e

if [ "$1" = "configure" ]; then
    systemctl enable wildos-boot-ok.service wildos-restore-points.service \
        wildos-restore-points.timer wildos-reset-copy.timer >/dev/null 2>&1 || true

    # On an installed PC (not the image build, not the live system): the
    # start-up files get the go-back hook, recovery's kernel goes to /boot
    # if the reset copy checks out, and the menu learns start-up recovery.
    if [ -d /run/systemd/system ] && [ ! -e /run/initramfs/live ] \
        && ! systemd-detect-virt --chroot --quiet; then
        if [ -d /var/lib/wildos/reset ]; then
            /usr/libexec/wildos/reset-copy boot-files >/dev/null 2>&1 || true
        fi
        # Btrfs PCs carry the hook from installation; they are rebuilt once
        # for 0.1.10, whose hook is the first that can start a restore point
        # on its layer in memory.
        if [ "$(findmnt -no FSTYPE /)" != btrfs ] || { [ -n "$2" ] && dpkg --compare-versions "$2" lt 0.1.10; }; then
            dracut --force >/dev/null 2>&1 || echo "wildos-recovery: the start-up files are updated at the next kernel update" >&2
        fi
        # The kernel running now works, so a newer one installed later gets
        # one start to prove itself before the PC goes back to this one.
        if [ -e /boot/grub/grubenv ] && ! grub-editenv /boot/grub/grubenv list | grep -q '^wildos_kernel_ok='; then
            grub-editenv /boot/grub/grubenv set "wildos_kernel_ok=$(uname -r)" || true
        fi
        if [ -e /boot/grub/grub.cfg ] && command -v update-grub >/dev/null; then
            update-grub >/dev/null 2>&1 || true
        fi
        # As the installer now does (install-nocow): no copy-on-write for
        # temporary files made from now on. Files already there keep theirs.
        if [ -d /var/tmp ] && [ "$(stat -f -c %T /var/tmp)" = btrfs ]; then
            chattr +C /var/tmp 2>/dev/null || true
        fi
        systemctl daemon-reload >/dev/null 2>&1 || true
        systemctl start wildos-restore-points.service >/dev/null 2>&1 || true
    fi
fi

#DEBHELPER#