Deleting a file at boot via tmpfiles.d

I have rolled out openSUSE 13.2 in a school environment, and unfortunately we’re dealing with a really annoying bug (#915760](https://bugzilla.suse.com/show_bug.cgi?id=915760)) that does not seem to be taken serious by the developers.

I found that a fairly reliable work-around is to delete /etc/resolv.conf, so that NetworkManager is forced to re-write it. Recently, I found that it refused to write DNS servers in there, because resolv.conf was just an empty file, doh.
Recently, I had a case where a student had connected to one wireless network, and then wanted to switch to another one, and then the DNS servers from the first one was preserved, so I had to manually delete resolv.conf and re-connect.

So therefore, I would like to ask. How can I configure tmpfiles.d in such a manner, that /etc/resolv.conf is deleted every time at boot-time, but at no other time. That way a user can always just re-boot their system, if there’s a problem. I was reading the man page, and I think it said something about the “r” parameter, but I am just not familiar enough with this new part of the system.

Reading the man page (and having done a small adaption in the past) I would say that

r /etc/resolv.conf

must do the trick. IMHO it is not difficult for you to test that.

But take care: you should not alter /usr/lib/tmpfiles.d/tmp.conf, but first make a copy of it to /etc/tmpfiles.d/tmp.conf and change there. Else on an update your changes might get lost.

Thanks, that was simpler than I imagined, just wanted to make sure as I am still unfamiliar with all the newer systemd-mechanics, still learning. :slight_smile:

It looks simple indeed (as soon as you know where and how), but I am curious. Did you test it? And does it function as you (and I ) intended?

Also, reading the man page, it noted that adding an exclamation mark (“r!”) makes it only delete the file during boot, and not at any random time. And yes it did indeed work in terms of deleting the file. The effect is that netconfig regenerates the default autogenerated file, which only contains some default commented out messages and the “search” parameter.

So in terms of file deletion, it did indeed work, what i input was this:

r! /etc/resolv.conf

I will probably test it out in the field in terms of NetworkManager soon, and I also just prodded my earlier bug report.

I overlooked that ! feature. In fact I can not find it at all in the man page I have here. But that is a 13.1 system, thus it maybe somethimng new.

In any case, thanks for reporting back. Always something to learn here :wink:

The mentioning of the usage of an exclamation mark is indeed in the 13.2 man page and not in the 31.1 man page of tmptfiles.d. A usefull extention IMHO.