LED control with systemd - example service

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

LED control with systemd - example service

Postby technosf » Tue Oct 29, 2013 6:05 am

Here's an FYI

Just updated my plug after quite a while :oops: , and found systemd :D

Figured this was a good time to lean systemsd via having the Pogo V2 leds do something....

The orange led lights up naturelment on boot, and remains, even after shutdown; I decided that instead I wanted the green led to signify network availability, and orange flashing on shutdown. I've ended up with this systemd service:
$this->bbcode_second_pass_code('', '
[Unit]
Description=LED control service
After=network.target

[Service]
Type=simple
RemainAfterExit=yes

ExecStartPre=/usr/bin/bash -c '/usr/bin/echo timer > /sys/class/leds/status\:green\:health/trigger'
ExecStartPre=/usr/bin/bash -c '/usr/bin/echo none > /sys/class/leds/status\:blue\:health/trigger'
ExecStart=/usr/bin/bash -c '/usr/bin/echo default-on > /sys/class/leds/status\:green\:health/trigger'
ExecStop=/usr/bin/bash -c '/usr/bin/echo timer > /sys/class/leds/status\:blue\:health/trigger'
ExecStopPost=/usr/bin/bash -c '/usr/bin/echo none > /sys/class/leds/status\:green\:health/trigger'
ExecStopPost=/usr/bin/bash -c '/usr/bin/echo none > /sys/class/leds/status\:blue\:health/trigger'

[Install]
WantedBy=multi-user.target
')

This simple service that remains after exit means that the pre-start and start tasks are run, but not the stop and post-stop. The stop tasks are run when the network target is stopped.

How it looks from boot is: orange, green flash, green - network is up!
From poweroff: orange flash, no-leds.

I'm not sure if I prefer no led when it's shutdown or a flashing orange led.

I hope this is useful to someone!
[size=85] MochaBin 5G || NSA325 [/size]
technosf
 
Posts: 147
Joined: Sat Jan 08, 2011 10:54 pm

Re: LED control with systemd - example service

Postby moonman » Tue Oct 29, 2013 6:10 am

The reason why your fron led is orange all the way by default is because you haven't set the proper machid in u-boot and your pogoplug is recognised as a sheeva reference board.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: LED control with systemd - example service

Postby technosf » Wed Oct 30, 2013 3:18 pm

$this->bbcode_second_pass_quote('moonman', 'T')he reason why your fron led is orange all the way by default is because you haven't set the proper machid in u-boot and your pogoplug is recognised as a sheeva reference board.


Lucky for me... Means I don't have to put in a systemd temp file to do that!
[size=85] MochaBin 5G || NSA325 [/size]
technosf
 
Posts: 147
Joined: Sat Jan 08, 2011 10:54 pm


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 22 guests