You are not logged in.

#1 2018-02-22 14:12:53

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

[SOLVED]What's wrong with this systemd service?

[Unit]
Description=Disable wake up from usb devices

[Service]
Type=oneshot
ExecStart=/usr/bin/echo disabled > /sys/bus/pci/devices/0000:00:1a.0/power/wakeup ; /usr/bin/echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup

[Install]
WantedBy=multi-user.target

Last edited by fluxboxer (2018-02-22 16:10:14)

Offline

#2 2018-02-22 14:14:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED]What's wrong with this systemd service?

Some context would be nice.  You should tell us what the symptoms are: how do you use it, what do you expect it to do, what does it actually do?

However, in this case, there is at least one obvious error: the ExecStart line is not parsed by a shell, so '>' is meaningless and ';' does not split commands.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-02-22 14:31:48

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

Sorry about the brevity.

Well, I've been trying to disable waking the computer by keyboard and mouse as they're vulnerable to my cats' paws.

I can manually just do it by

sudo bash -c 'echo disabled > /sys/bus/pci/devices/0000:00:1a.0/power/wakeup && echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup'

but it's not retained after a reboot. So I want to automate it. I've managed (very very easily) to do it by just this (f)crontab

@reboot echo disabled > /sys/bus/pci/devices/0000:00:1a.0/power/wakeup && echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup

Yet I prefer to do it with the default system resources of Arch (systemd), if possible.

My service doesn't work. When running manually by

/etc/systemd/system/buttonwakeup.service

I get

bash: /etc/systemd/system/buttonwakeup.service: Permission denied

Last edited by fluxboxer (2018-02-22 14:35:16)

Offline

#4 2018-02-22 14:39:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED]What's wrong with this systemd service?

If that's the command you want to run, that's the command that should be in the ExecStart line:

ExecStart=/usr/bin/bash -c 'echo disabled > /sys/bus/pci/devices/0000:00:1a.0/power/wakeup && echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup'

However there's likely a better way:
https://wiki.archlinux.org/index.php/Sy … rary_files

Last edited by Trilby (2018-02-22 14:39:20)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2018-02-22 14:48:44

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

I've already tried your suggestion without success. Will look at your link now.

Offline

#6 2018-02-22 14:51:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED]What's wrong with this systemd service?

What does "without success" mean?  What's in the journal?  What is the status of the service?  My first suggestion is ugly as hell (there is likely a much slimer sysctl command that would be better) but it should most definitely work if the service is started at the appropriate time.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2018-02-22 14:53:54

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED]What's wrong with this systemd service?

using tmpfiles on files in /sys has been an issue, it's a race condition since there's no dependency checks that the files exist before tmpfiles is run. You're better of with a udev rule for this.

Offline

#8 2018-02-22 15:14:06

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

@Trilby

The "status" has always reported "success" (erroneously). I'll re-enable the service, reboot and look into journal.

On the other hand, I feel it's foolish to fight with systemd, while there's a very easy solution with cron.

Offline

#9 2018-02-22 15:16:08

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED]What's wrong with this systemd service?

It's very possible you have the same race condition problem with the .service file that I mentioned with tmpfiles. Again, udev rule.

Offline

#10 2018-02-22 15:27:47

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

Thank you.

By the way, the journalctls:

Feb 21 04:01:53 evo systemd[1]: Starting Disable wake up from usb devices...
Feb 21 04:01:53 evo echo[338]: disabled > /sys/bus/pci/devices/0000:00:1a.0/power/wakeup && /usr/bin/echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup
Feb 21 04:01:53 evo systemd[1]: Started Disable wake up from usb devices.

Offline

#11 2018-02-22 15:32:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED]What's wrong with this systemd service?

There's no way that's from the ExecStart that Trilby gave you.

Offline

#12 2018-02-22 16:04:00

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

No, it's from a previous trial; I'll retry bash -c.

Offline

#13 2018-02-22 16:09:50

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

Well, I'm embarrassed; it works. I'm (almost) sure that I've tried it before along with some other things. Sorry for the noise. Thank you.

Offline

#14 2018-02-22 16:11:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED]What's wrong with this systemd service?

It's not noise.  And Scimmia is right - a udev rule would be much cleaner.  Mine was an ugly hack primarily only to highlight why your initial attempt didn't work (because ExecStart lines are not parsed by a shell).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#15 2018-02-22 17:06:43

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: [SOLVED]What's wrong with this systemd service?

Thank you.

Offline

Board footer

Powered by FluxBB