description "FUSE filesystem for LXC"
author "Stéphane Graber <stgraber@ubuntu.com>"

start on starting lxc or starting lxd or runlevel [2345]
stop on runlevel [06]

respawn

pre-start script
    [ ! -e /run/container_type ] || { stop; exit 0; }
end script

exec /usr/bin/lxcfs /var/lib/lxcfs

post-stop script
    [ -e /run/container_type ] && exit

    # Cleanup in case of crash
    fusermount -u /var/lib/lxcfs 2> /dev/null || true
    [ -L /etc/mtab ] || \
        sed -i "/^lxcfs \/var\/lib\/lxcfs fuse.lxcfs/d" /etc/mtab
end script
