public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] numlock script and systemd
@ 2014-06-09  2:39 covici
  2014-06-09  4:00 ` Canek Peláez Valdés
  0 siblings, 1 reply; 3+ messages in thread
From: covici @ 2014-06-09  2:39 UTC (permalink / raw
  To: gentoo-user

Hi.  I would like to use my /etc/init.d/numlock script with systemd, but
systemctl start just says warning numlock is already starting.  I
thought that if a service  was not there it would use something in
/etc/init.d and create one, so what am I doing wrong?

Here is the script
----------cut here ----------
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.

description="Turns numlock on for the consoles."

ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}

depend()
{
	need localmount
	keyword -openvz -prefix -vserver -lxc
}

_setleds()
{
	[ -z "$1" ] && return 1

	local dev=/dev/tty t= i=1 retval=0
	[ -d /dev/vc ] && dev=/dev/vc/

	while [ $i -le $ttyn ]; do
		setleds -D "$1"num < $dev$i || retval=1
		: $(( i += 1 ))
	done

	return $retval
}

start()
{
	ebegin "Enabling numlock on ttys"
	_setleds +
	eend $? "Failed to enable numlock"
}

stop()
{
	ebegin "Disabling numlock on ttys"
	_setleds -
	eend $? "Failed to disable numlock"
}
------------- cut here ----------

It does work under openrc.

Thanks in advance for any suggestions.

-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

         John Covici
         covici@ccs.covici.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-user] numlock script and systemd
  2014-06-09  2:39 [gentoo-user] numlock script and systemd covici
@ 2014-06-09  4:00 ` Canek Peláez Valdés
  2014-06-09  5:48   ` covici
  0 siblings, 1 reply; 3+ messages in thread
From: Canek Peláez Valdés @ 2014-06-09  4:00 UTC (permalink / raw
  To: gentoo-user

On Sun, Jun 8, 2014 at 9:39 PM,  <covici@ccs.covici.com> wrote:
> Hi.  I would like to use my /etc/init.d/numlock script with systemd, but
> systemctl start just says warning numlock is already starting.  I
> thought that if a service  was not there it would use something in
> /etc/init.d and create one, so what am I doing wrong?

That only works for "normal" SysV scripts. OpenRC scripts are similar,
but different enough so that systemd on Gentoo doesn't even tries to
load them.

To do what you want, there are several ways: for example you can
create a service for each terminal and enable all of them, or you can
create a template service, and create instances for all your
terminals.

However, in systemd all the VTs are not started until you switch to
them (except the first one), sou you have the start the services for
each terminal *after* getty@ttyN.service, with N=1,2,...

I think the easiest option is for you to override getty@.service, by
creating /etc/systemd/systemd/getty@.service.d/numlock.conf, and
putting:

------------------------
ExecStartPost=setleds -D +num < /dev/%I
------------------------

in int. Then you only do "systemctl --system daemon-reload", and if
everything works, you should have numlock activated in each VT when
you switch to them.

Check man 5 systemd.unit; the proper explanation for all the options
is given there.

Regards.
-- 
Canek Peláez Valdés
Profesor de asignatura, Facultad de Ciencias
Universidad Nacional Autónoma de México


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-user] numlock script and systemd
  2014-06-09  4:00 ` Canek Peláez Valdés
@ 2014-06-09  5:48   ` covici
  0 siblings, 0 replies; 3+ messages in thread
From: covici @ 2014-06-09  5:48 UTC (permalink / raw
  To: gentoo-user

Canek Peláez Valdés <caneko@gmail.com> wrote:

> On Sun, Jun 8, 2014 at 9:39 PM,  <covici@ccs.covici.com> wrote:
> > Hi.  I would like to use my /etc/init.d/numlock script with systemd, but
> > systemctl start just says warning numlock is already starting.  I
> > thought that if a service  was not there it would use something in
> > /etc/init.d and create one, so what am I doing wrong?
> 
> That only works for "normal" SysV scripts. OpenRC scripts are similar,
> but different enough so that systemd on Gentoo doesn't even tries to
> load them.
> 
> To do what you want, there are several ways: for example you can
> create a service for each terminal and enable all of them, or you can
> create a template service, and create instances for all your
> terminals.
> 
> However, in systemd all the VTs are not started until you switch to
> them (except the first one), sou you have the start the services for
> each terminal *after* getty@ttyN.service, with N=1,2,...
> 
> I think the easiest option is for you to override getty@.service, by
> creating /etc/systemd/systemd/getty@.service.d/numlock.conf, and
> putting:
> 
> ------------------------
> ExecStartPost=setleds -D +num < /dev/%I
> ------------------------
> 
> in int. Then you only do "systemctl --system daemon-reload", and if
> everything works, you should have numlock activated in each VT when
> you switch to them.
> 
> Check man 5 systemd.unit; the proper explanation for all the options
> is given there.

Thanks, I have put it in, we shall see what happens on the next reboot.


-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

         John Covici
         covici@ccs.covici.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-09  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-09  2:39 [gentoo-user] numlock script and systemd covici
2014-06-09  4:00 ` Canek Peláez Valdés
2014-06-09  5:48   ` covici

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox