Skip to content

Add path to command to configurable options #74

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

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

bugabinga
Copy link
Contributor

@bugabinga bugabinga commented Feb 25, 2019

This commit makes it a little bit more comfortable to add a custom script for use cases such as in #73.
When the variable is empty/undefined ldm simply prints The callback script isn't executable! but works fine.
I am unsure about the exact quoting rules in systemd service files.
Maybe the COMMAND_PATH should be wrapped in " in case of whitespace in path?

Tested this with following config:

/etc/ldm.conf

MOUNT_OWNER=oli
BASE_MOUNTPOINT=/home/oli/Mounts
FMASK_DMASK=0177,0077
COMMAND_PATH=/etc/ldm_notify.sh

/etc/ldm_notify.sh

#!/bin/sh
env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /usr/bin/toastify send --icon mount --app-name ldm "$LDM_ACTION" "Mounted $LDM_NODE($LDM_FS) in $LDM_MOUNTPOINT."

This commit makes it a little bit more comfortable to add a custom script for use cases such as in LemonBoy#73.
When the variable is empty/undefined `ldm` simply prints `The callback script isn't executable!` but works fine.
I am unsure about the exact quoting rules in systemd service files.
Maybe the `COMMAND_PATH` should be wrapped in **"** in case of whitespace in path?

Tested this with following config:

/etc/ldm.conf
```sh
MOUNT_OWNER=oli
BASE_MOUNTPOINT=/home/oli/Mounts
FMASK_DMASK=0177,0077
COMMAND_PATH=/etc/ldm_notify.sh
```
/etc/ldm_notify.sh
```sh
#!/bin/sh
env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /usr/bin/toastify send --icon mount --app-name ldm "$LDM_ACTION" "Mounted $LDM_NODE($LDM_FS) in $LDM_MOUNTPOINT."
```
@LemonBoy
Copy link
Owner

Thanks for the PR!

When the variable is empty/undefined ldm simply prints The callback script isn't executable! but works fine.

Oops, that's fixed now :)

I'd introduce an EXTRA_ARGS variable that's just appended after the usual options so that you can write EXTRA_ARGS=-c /my/path without having to worry too much about optional or missing arguments.

Don't forget to update the ldm.pod file too (GitHub kindly decided to stop rendering it, sigh)

The systemd service appends the environment variable `EXTRA_ARGS` to the ldm executable.
This variable can optionally be set in `/etc/ldm.conf` in order to append any command line flag to `ldm`.
For example: `-c <path_to_some_script>`.
@bugabinga
Copy link
Contributor Author

EXTRA_ARGS is good idea.

Can you check, that the rendering of ldm.pod is okay?
I have never seen pod files before ;)

Btw, Github renders ldm.pod fine when you click it directly.
Only the symlink README.pod is broken.
Very weird.

@LemonBoy
Copy link
Owner

I have never seen pod files before ;)

It's a pretty nice format and with pod2man you can easily produce the man pages with no extra effort.

Can you check, that the rendering of ldm.pod is okay?

Github is nice enough to render the diff for you :)

Btw, Github renders ldm.pod fine when you click it directly.
Only the symlink README.pod is broken.
Very weird.

Such is technology, it used to work a couple of weeks ago :\

@LemonBoy LemonBoy merged commit 1764055 into LemonBoy:master Feb 26, 2019
@bugabinga bugabinga deleted the patch-1 branch February 26, 2019 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants