-
Notifications
You must be signed in to change notification settings - Fork 1
Add example systemd service files #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
obbardc
wants to merge
6
commits into
brgl:main
Choose a base branch
from
obbardc:wip/obbardc/add-systemd-service
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d0991b
Add example systemd service files
obbardc 8bdeb3a
Document example systemd service files
obbardc 489531c
Remove outdated sysvinit script
obbardc 1fcbd31
Assume default mountpoint for the systemd service
obbardc d980773
Add service target.wants symlinks
obbardc eb4522e
Install systemd service files
obbardc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| [Unit] | ||
| Description=User-space, libgpiod-based compatibility layer for linux GPIO sysfs interface | ||
|
|
||
| # There are two standard locations for the mountpoint `/sys/class/gpio` and `/run/gpio`. | ||
| # This example service uses the former. | ||
| [Service] | ||
| RuntimeDirectory=gpio | ||
| Type=simple | ||
| ExecStart=/usr/bin/gpiod-sysfs-proxy /sys/class/gpio -f -o nonempty -o allow_other -o default_permissions -o entry_timeout=0 -o attr_timeout=0 | ||
| ExecStop=/bin/umount /sys/class/gpio | ||
| Restart=always | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| [Unit] | ||
| Description=Remount of sysfs for gpiod-sysfs-proxy | ||
| ConditionPathExists=!/sys/class/gpio | ||
|
|
||
| [Mount] | ||
| DirectoryMode=0700 | ||
| What=sysfs | ||
| Where=/run/gpio/sys | ||
| Type=sysfs | ||
| Options=nosuid,nodev,noexec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| [Unit] | ||
| Description=Overlay on top of /sys/class adding the gpio class directory | ||
| Before=gpiod-sysfs-proxy.service | ||
| After=run-gpio-sys.mount | ||
| ConditionPathExists=!/sys/class/gpio | ||
|
|
||
| [Mount] | ||
| RuntimeDirectory=gpio/class/gpio | ||
| DirectoryMode=0755 | ||
| What=overlay | ||
| Where=/sys/class | ||
| Type=overlay | ||
| Options=upperdir=/run/gpio/class,lowerdir=/run/gpio/sys/class,workdir=/run/gpio/work,ro,nosuid,nodev,noexec,relatime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../run-gpio-sys.mount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../sys-class.mount |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This installs these files unconditionally. In my meta-openembedded recipe I only do this if the user selected the - admittedly quite intrusive -
sys-class-mountPACKAGECONFIG switch. Should we have a corresponding switch here as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we can have a switch here without a lot of fudging around - that's why I made the python package install the most useful default service by default.
Do we really need to support both paths? I don't know enough about this really, but I suspect it'd make sense to support one by default in distros like debian etc?
Perhaps it'd make sense to install using a default path and push users to README for information to use alternate paths? again, I am not entirely sure here, but surely for modern installs there is a sensibe default? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I never really considered this could be packaged in Debian. :) Is mounting an overlay over
/sys/classsomething Debian would accept as the default? Sounds quite risky to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me, if you install this you kind of need it to work :-)
Alternatively in the python install we could install 2x systemd services (one for each path, or a template and 2x services extending the template) to a doc dir (e.g. not install them), then in yocto/debian we could install the script by default and have the services as as separate packages, and let users choose which package they want to install (and in yocto you can keep the same var, just install different services to the right place) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or (for yocto) possibly two mutually-exclusive packages: gpiod-sysfs-proxy-systemd-overlay and gpiod-sysfs-proxy-systemd-tmp with the former installing the /sys/class overlay units?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, and in this python installer i should put the service files into a documentation dir.
Need to figure out how to make the services extend another service so we don't duplicate code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be too much to ask to also update the yocto recipe if you're doing it? :)