Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Help needed debugging oneshot service. (Read 77 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Help needed debugging oneshot service.


I have setup a oneshot service to set my laptop's battery charge threshold.
Here is the execline script I wrote.
Code: [Select]
#!/usr/bin/execlineb -P
pipeline { printf "60" }
tee /sys/class/power_supply/BAT1/charge_control_end_threshold

I've also made sure to add mount-sysfs as a dependency, so it executes after /sys/ has been mounted.
For some reason my script still does not wok.

So I modified it a little bit to see where it went wrong
Code: [Select]
#!/usr/bin/execlineb -P

foreground { touch /tmp/executed_before }

backtick -E output {
  pipeline { printf "60" }
  foreground { tee /sys/class/power_supply/BAT1/charge_control_end_threshold }
  cat /sys/class/power_supply/BAT1/charge_control_end_threshold
}

touch /tmp/executed_after${output}

Running it manually shows:
Code: [Select]
[userman@admin ~]$ doas s6-rc -u change battery-limit
[userman@admin ~]$ ls /tmp/
dbus-BTKoOSfitJ  dbus-QHIFxt8UXP  executed_after6060  executed_before
[userman@admin ~]$ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
60
[userman@admin ~]$

But when it executes on boot, it shows:
Code: [Select]
[userman@admin ~]$ ls /tmp/
dbus-BTKoOSfitJ  executed_before
[userman@admin ~]$ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
100
So I have 2 questions:
  • What is happening here?
  • Is there a way to check the output/exit code of a oneshot service without having to modify it?

Re: Help needed debugging oneshot service.

Reply #1
I have solved the issue. I added mount-filesystems as a dependency of my service and now it works.

Code: [Select]
[userman@admin battery-limit]$ ls *
type  up

dependencies.d:
mount-filesystems