Rc.local in my template does nothing

I am trying to use the rc.local to launch my startup script. If I open terminal in my fedora template and navigate to the directory /rw/config/ and then type ./rc.local it starts my script perfectly even though it fails because it doesn’t have any net settings. However, any vm based on this template when started does nothing.
So the changes in the template aren’t carrying over to the VM’s because nothing happens when they start. If I navigate to the started VM /rw/config/ directory and the cat the rc.local file, nothing is there, nor are my script files in the directory.
I pretty new to Qubes so I am obviously misunderstanding something.
I searched for rc.local but found nothing helpful for me. The permissions of the file are as follows:

-rwxr-xr-x 1 root root 366 Oct 11 14:47 rc.local

rc.local is not inherited from the template.
If you want some script to run at boot in template based Qubes, then
you can set it up in the template, perhaps using systemd. That will be
inherited in qubes using the template.

I never presume to speak for the Qubes team.
When I comment in the Forum or in the mailing lists I speak for myself.

I’m facing the same problem. And there’s a difference between Fedora and Debian.

Modifying /rw/config/rc.local in a Debian template is inherited in the Disposable Qube based on that template.

Modifying /rw/config/rc.local in a Fedora template is NOT inherited in the Disposable Qube based on that template.

How can I modify rc.local in a Fedora template to make sure it is inherited by the Disposable Qube based on that template?

@unman what does “using systemd” mean and how can I use it?

rc.local in my AppVM does nothing.

Do I misunderstand? I write my commands that I want to run exactly as if it were in the shell, save and restart. They survive the reboot but the command never runs.

Example “touch ~/test” - does not create the file after reboot. The command is in my rc.local after reboot.

This script is executed as root, so touch ~/test will create /root/test.

it didn’t create either, I also tried “sudo -u user touch ~/test” can you give me a command to put in my rc.local that works for you?

touch /home/user/rootfile
su -c "touch /home/user/userfile" user

Is your rc.local executable?

i may be encountering this same/similar issue in R4.2 with a servicevm based on fedora-38-xfce template, trying to run wg-quick up /home/user/a-wireguard.conf on start.

touch works fine and creates a file.

running rc.local manually creates the test file but doesn’t run wg-quick. running wg-quick manually works fine.

i’ve checked many times now the line in rc.local and there are no typos or anything. is there something else i can investigate? it only mild inconvenience as i just run the command manually when the servicevm boots, but would be great to work. otherwise it sounds like switching it over to be based on debian-12 would fix the issue.

I had the same problem with wg-quick only on Fedora. If you send the stdout/err to a file when executing the command from rc.local, it says that it can’t find the config file even if it exists. This is due to the introduction of selinux in all Fedora templates since 4.2, which blocks wg-quick from accessing the file. One way to fix this is to set wireguard_t to permissive:

sudo semanage permissive -a wireguard_t

Then you can do this in /rw/config/rc.local:

ln -s /path/to/config /etc/wireguard/
wg-quick up config_name

yep works perfectly, many thanks!

1 Like