You are not logged in.

#1 2012-11-01 14:00:45

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Understanding systemd units/services (particularly, rc.local)

I followed the Arch wiki for re-writing rc.local by creating the following:

$ cat /etc/systemd/system/rc.local.service 
[Unit]
Description=/etc/rc.local

[Service]
Type=oneshot
ExecStart=/usr/local/bin/rc.local
TimeoutSec=0
RemainAfterExit=0

[Install]
WantedBy=multi-user.target

And here is my rc.local script called by the above:

truecrypt -t --protect-hidden=no -k "" --filesystem=none --slot=1 /dev/sda4

mount /media/vault &

chown jwhendy:wheel /sys/class/backlight/acpi_video0/brightness &

Under initscripts, I was prompted for my truecrypt volume password on boot, just before text login. I change permissions on my brightness file so that a script can manually adjust based on my openbox rc.xml set up hotkeys. (Actually, I haven't checked to see if I still need these under systemd. Keys did not work via xbacklight, so I just manually set the values in the brightness file, which works fine for me.)

In any case, I've added rc.local.service via:

$ sudo systemctl enable rc.local.service

And I can see that it's indeed enabled:

$ sudo systemctl list-unit-files
/ rc # (search for "rc")
rc.local.service                       enabled 

At boot:
1) I'm not prompted for my truecrypt password

2) My brightness file permissions are not changed

What am I doing wrong? What does it mean that systemd "starts the rc.local service" at boot? Is it going to interrupt the boot process to handle any password requests coming from the script executed by the service? Even if that's not the case, I'm still confused as to why the backlight permissions line wouldn't work.

While the wiki indicates how to emulate rc.local, is there a clear-cut set of instructions about how to do what with systemd services? I'd love something like, "Are you trying to mount drives at boot? You need a service file like this." "Are you trying to execute a command? Use something like this."

At the present moment, the word "services" is hanging me up. They seem like something more akin to daemons -- running in the background, checking for certain changes at which point they automatically do something or provide some functionality. I already enabled my rc.conf daemons via systemd services... these are more like actions that need to be run once at boot and that's it. Does that call for a "service"?

Thanks for any suggestions.

----------
P.S. Despite transitioning to the "proper files" (/etc/localtime, /etc/locale, etc.") vs. rc.conf some time ago and then following the wiki, I'm just slightly confused as to whether I'm purely on systemd. The only remaining package that held me up was installing `systemd-sysvcompat` because I no longer had a `reboot` command after removing it. This, in turn, brought in `sysvinit-tools`. Should I need these, or are these messing with anything in order to be "purely on systemd"?

Offline

#2 2012-11-01 15:06:21

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: Understanding systemd units/services (particularly, rc.local)

You need to use systemd-ask-password - the service standard input is not connected to the terminal.

Offline

#3 2012-11-08 17:24:41

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: Understanding systemd units/services (particularly, rc.local)

@brain0 -- I read about this and tried a foolish way of using it; how does one incorporate systemd-ask-password with the service requiring a password?

Offline

Board footer

Powered by FluxBB