Re: [qubes-users] Autostart on login in minimal templates

2020-01-12 Thread Abel Luck



Claudia:
> Try putting `systemctl daemon-reload` in rc.local. I haven't tried it, but 
> this should work, as rc.local itself resides on /rw, so /rw has to be 
> available by that time. (Arguably the stock rc.local in Qubes templates 
> should be preinstalled with this line. But then, arguably, systemd should 
> always automatically reload units any time it mounts something.)

I've tried this, and unfortunately it doesn't work IF the goal is to get
the units in /usr/local to participate in the boot process. This is
because by the time qubes-misc-post.service executes
/rw/config/rc.local, the boot process is already well in progress. See
my other reply for more details.

If the goal is simply to make the /usr/local units available to systemd,
for later start/stopping, then it will work. But you cannot enable them
to be started at boot.

I suppose one could add `systemctl daemon-reload` to rc.local and then a
series of `systemctl start your-thing.service` statements, but you still
miss out on the benefits of systemd's 'enable' (After,Before, etc).

~abel

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/ad4e8e45-d644-ba33-06a0-2801160bcf7c%40guardianproject.info.


Re: [qubes-users] Autostart on login in minimal templates

2020-01-12 Thread Claudia
January 12, 2020 11:33 AM, "Abel Luck"  wrote:

> The systemd route does seem promising. Thanks.
> 
> If I edited the template vm, I could just put my unit file in
> /etc/systemd/system and it would work fine.
> 
> However I'd like to do this for a specific AppVm, so I dropped the unit
> file in /usr/local/lib/systemd/system. This file persists across boots
> as expected, however systemd doesn't load units from it until I
> daemon-reload after boot.
> 
> I suppose this is because /usr/local is symlinked from /rw/usrlocal
> sometime after systemd has loaded its units.
> 
> Is there anyway to get systemd to load units from
> /usr/local/lib/systemd/system as part of appvm boot?
> 
> ~abel

Try putting `systemctl daemon-reload` in rc.local. I haven't tried it, but this 
should work, as rc.local itself resides on /rw, so /rw has to be available by 
that time. (Arguably the stock rc.local in Qubes templates should be 
preinstalled with this line. But then, arguably, systemd should always 
automatically reload units any time it mounts something.)

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/d27f149b5018ef1a57c971707e224ef7%40disroot.org.


Re: [qubes-users] Autostart on login in minimal templates

2020-01-12 Thread Abel Luck


Abel Luck:
> The systemd route does seem promising. Thanks.
> 
> If I edited the template vm, I could just put my unit file in
> /etc/systemd/system and it would work fine.
> 
> However I'd like to do this for a specific AppVm, so I dropped the unit
> file in /usr/local/lib/systemd/system. This file persists across boots
> as expected, however systemd doesn't load units from it until I
> daemon-reload after boot.
> 
> I suppose this is because /usr/local is symlinked from /rw/usrlocal
> sometime after systemd has loaded its units.
> 
> Is there anyway to get systemd to load units from
> /usr/local/lib/systemd/system as part of appvm boot?
> 
> ~abel
> 
> Claudia:
>> January 11, 2020 2:06 PM, "Abel Luck"  wrote:
>>
>>> Hi there,
>>>
>>> Using the fedora and debian minimal templates, how can I execute a
>>> script on *login*? I'm aware of /rw/config/rc.local, but that runs on
>>> system boot.
>>>
>>> Rather, I want to run something after X11 has initialized and my user is
>>> logged in.
>>>
>>> Since no DE is installed, .desktop files in ~/.config/autostart are not
>>> executed in the minimal templates
>>>
>>> ~abel
>>
>> Would .xinitrc work?
>>
>> Systemd units with After=graphical.target and properly configured User=, 
>> Display=, Session=, Seat=, and/or whatever else might be necessary. Or maybe 
>> user-mode systemd units. https://wiki.archlinux.org/index.php/Systemd/User
>>
>> Or maybe rc.local with `systemctl is-system-running --wait` before your 
>> commands - I often have to use this with qvm-run. Running from rc.local 
>> though, commands might not be running as the right 
>> user/session/seat/slice/scope/whatever, I don't know.

Oops, sorry for the top post D:

I did some more research and this appears to be a systemd limitation:
https://github.com/systemd/systemd/issues/8307

/rw/usrlocal is mounted to /usr/local as part of
qubes-mount-dirs.service when a vm is booting. This means the unit files
in /usr/local are not visible to systemd.

As poettering state in that issue: "unit files have to reside on a
partition that is mounted at the moment the host PID 1 is invoked. i.e.
either on the root partition or some other partition that the initrd
premounts."

This is quite sad. I have several use cases for app-vm specific systemd
units:

* Automount network drive on boot (for backupvm)
* Run some special daemons on boot
* Execute scripts on user login

I guess I'll just need to revist the use of rc scripts :/ (ala
https://entropux.net/article/systemd-rc-local-service-with-qubes/)

~abel

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/2740ac28-eb6d-c43b-2bf9-67a7ca13601b%40guardianproject.info.


Re: [qubes-users] Autostart on login in minimal templates

2020-01-12 Thread Abel Luck
The systemd route does seem promising. Thanks.

If I edited the template vm, I could just put my unit file in
/etc/systemd/system and it would work fine.

However I'd like to do this for a specific AppVm, so I dropped the unit
file in /usr/local/lib/systemd/system. This file persists across boots
as expected, however systemd doesn't load units from it until I
daemon-reload after boot.

I suppose this is because /usr/local is symlinked from /rw/usrlocal
sometime after systemd has loaded its units.

Is there anyway to get systemd to load units from
/usr/local/lib/systemd/system as part of appvm boot?

~abel

Claudia:
> January 11, 2020 2:06 PM, "Abel Luck"  wrote:
> 
>> Hi there,
>>
>> Using the fedora and debian minimal templates, how can I execute a
>> script on *login*? I'm aware of /rw/config/rc.local, but that runs on
>> system boot.
>>
>> Rather, I want to run something after X11 has initialized and my user is
>> logged in.
>>
>> Since no DE is installed, .desktop files in ~/.config/autostart are not
>> executed in the minimal templates
>>
>> ~abel
> 
> Would .xinitrc work?
> 
> Systemd units with After=graphical.target and properly configured User=, 
> Display=, Session=, Seat=, and/or whatever else might be necessary. Or maybe 
> user-mode systemd units. https://wiki.archlinux.org/index.php/Systemd/User
> 
> Or maybe rc.local with `systemctl is-system-running --wait` before your 
> commands - I often have to use this with qvm-run. Running from rc.local 
> though, commands might not be running as the right 
> user/session/seat/slice/scope/whatever, I don't know.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/8cbe83a5-0b2f-b23f-8f41-7221804f2b44%40guardianproject.info.


Re: [qubes-users] Autostart on login in minimal templates

2020-01-11 Thread Claudia
January 11, 2020 2:06 PM, "Abel Luck"  wrote:

> Hi there,
> 
> Using the fedora and debian minimal templates, how can I execute a
> script on *login*? I'm aware of /rw/config/rc.local, but that runs on
> system boot.
> 
> Rather, I want to run something after X11 has initialized and my user is
> logged in.
> 
> Since no DE is installed, .desktop files in ~/.config/autostart are not
> executed in the minimal templates
> 
> ~abel

Would .xinitrc work?

Systemd units with After=graphical.target and properly configured User=, 
Display=, Session=, Seat=, and/or whatever else might be necessary. Or maybe 
user-mode systemd units. https://wiki.archlinux.org/index.php/Systemd/User

Or maybe rc.local with `systemctl is-system-running --wait` before your 
commands - I often have to use this with qvm-run. Running from rc.local though, 
commands might not be running as the right 
user/session/seat/slice/scope/whatever, I don't know.

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/cb9602caf03cf1401b51e2bb40a8cbb2%40disroot.org.


[qubes-users] Autostart on login in minimal templates

2020-01-11 Thread Abel Luck
Hi there,

Using the fedora and debian minimal templates, how can I execute a
script on *login*? I'm aware of /rw/config/rc.local, but that runs on
system boot.

Rather, I want to run something after X11 has initialized and my user is
logged in.

Since no DE is installed, .desktop files in ~/.config/autostart are not
executed in the minimal templates

~abel

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/e17927d0-d99e-deb9-ee31-4c655eddca2d%40guardianproject.info.