Prevent disposable templates from starting

Hello,

i often use the disposable template instead of starting a disposable. Thus i have have unwanted leftovers from previous usage in the qube. Is there any way how i can prevent starting the template and only allow running dispoables from it?

I already attempted to use the prohibt start option in the qubes manager but that prevents also starts of the disposables.

1 Like

I think this would be a nice feature request to post on the tracker, as I run into the same issue.

2 Likes

I have some ideas in mind but it would prevent running the template to configure it, I guess you might need to run the template for a good reason occasionally?

Maybe just change the template name and tag it with ZZZZZZZZZZZ in front of its name :smiley: or change the color? The idea is to not have the template name in your way, so you can’t mix things up.

You could use this Automatically restart a qube on stop but instead of starting the qube, it would stop it. If you want to use the template, you would need to manually stop the systemd service.

1 Like

As a workaround, what I do is I have this code snippet in /rw/config/rc.local on my default-dvm template:

if [ "$(/usr/bin/hostname)" == "default-dvm" ] ; then
    export DISPLAY=":0"
    I=0
    while [ $I -le 15 ] && ! xset q >/dev/null ; do
        let I=$I+1
        sleep 1
    done
    XMESSAGE="$(echo -e "You just started \`$(/usr/bin/hostname)',\nwhich is a dvm-template, not a disp-vm.\nDo you want to shut it down?")"
    xmessage -center -timeout 60 -buttons Yes,No -default No "$XMESSAGE"
    XMSG_STATUS=$?
    if   [ $XMSG_STATUS -eq 0 -o $XMSG_STATUS -eq 102 -o $XMSG_STATUS -eq 1 ] ; then
        /bin/true
    elif [ $XMSG_STATUS -eq 101 ] ; then
        poweroff
    else
        echo "ERROR: incorrect xmessage STATUS (\`$XMSG_STATUS')." >&2
    fi
fi
1 Like

Instead of verifying the hostname, you could use

if [ "$(qubesdb-read /qubes-vm-persistence)" = "rw-only" ]
then
    echo "you are not in a disposable qube"
fi

The value of /qubes-vm/persistence in a disposable is “none”.

2 Likes