On 06/20/2014 03:46 PM, [email protected] wrote:
Jc García <[email protected]> wrote:

2014-06-20 11:26 GMT-06:00  <[email protected]>:

I tried your idea of a shell script like this
[Service]
ExecStartPost=/bin/bash -c "setleds -D -num </dev/%I"
I tried your line on my system, and rebooted, and didn't see any problem.

I have:

/etc/systemd/system/getty\@.service.d/numlock.conf:
[Service]
#ExecStartPost=-/bin/sh -c '/usr/bin/setleds -D -num </dev/%I'
ExecStartPost=/bin/bash -c "/usr/bin/setleds -D -num </dev/%I"


After reboot I logged in using tty1, here's the output of

systemctl status -l [email protected]:
-----
● [email protected] - Getty on tty1
    Loaded: loaded
(/etc/systemd/system/getty.target.wants/../../../../usr/lib/systemd/system/[email protected];
enabled)
   Drop-In: /etc/systemd/system/[email protected]
            └─numlock.conf
    Active: active (running) since vie 2014-06-20 12:04:47 CST; 19min ago
      Docs: man:agetty(8)
            man:systemd-getty-generator(8)
            http://0pointer.de/blog/projects/serial-console.html

----->This line:
   Process: 625 ExecStartPost=/bin/bash -c /usr/bin/setleds -D -num
</dev/%I (code=exited, status=0/SUCCESS)


  Main PID: 624 (login)
    CGroup: /system.slice/system-getty.slice/[email protected]
            ‣ 624 /bin/login --

jun 20 12:05:17 jdesk login[624]: pam_unix(login:session): session
opened for user jc by LOGIN(uid=0)
-----

But it did not work, it kept restarting and systemd eventually refused
to start.  When I commented out the line, it started OK.


Post the actual output you get from systemd when is trying to start a
getty@ service, to see what's going on in your machine.
OK, here is what I get when I enable the ExecStartPost line:


bash[28875]: KDGKBLED: Inappropriate ioctl for device
bash[28875]: Error reading current flags setting. Maybe you are not on
the console?
bash[28879]: KDGKBLED: Inappropriate ioctl for device
bash[28879]: Error reading current flags setting. Maybe you are not on
the console?
bash[28883]: KDGKBLED: Inappropriate ioctl for device
bash[28883]: Error reading current flags setting. Maybe you are not on
the console?
bash[28887]: KDGKBLED: Inappropriate ioctl for device
bash[28887]: Error reading current flags setting. Maybe you are not on
the console?

% cat /etc/systemd/system/[email protected]/activate-numlock.conf
[Service]
ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'


That works here to turn numlock on (source ArchLinux wiki)

Reply via email to