Skip to content
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

Improvements and cleanup #19

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

oliv3r
Copy link

@oliv3r oliv3r commented Oct 24, 2018

This series contains a bunch of fixes and cleanups to improve overall consistency and quality. As it's quite a huge changeset (touching pretty much every single line) it is thus recommended to review it per commit (as intended).

Olliver

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The current file is mixing tabs and spaces on various indents. Since
tabs are use the most, I suppose that's what was intended to be used.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Ensure consistent editing where supported by adding the optional
.editorconfig. This does not enforce any style and only works if the
editor supports it (via a plugin for example).

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
By putting udevadm in a variable we only have one place to have the whole
string, could easily replace it with UDEVADM="$(command -v udevadm)" or
otherwise.

Furthermore add a test for the executability of the binary.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
As udevadm, systemd-escape and the various service files are hard requirement,
list it as explicitly so in the debian control file.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
According to the udevadm manual page --export produces a parseable list.

  -x, --export
      Print output as key/value pairs. Values are enclosed in single quotes.

So using grep to drop lines that are not key/value pairs is just a
resource waste without doing anything.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
By putting blkid in a variable we only have one place to have the whole
string, could easily replace it with BLKID="$(command -v blkid)" or
otherwise.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The busybox variant of blkid does not work by default with usbmount. So
ensure we depend on the real thing.

Things not supported:
-p gets ignored and 'USAGE' is not returned.
-o value is not supported
-s FIELD is ignored

It basically just dumps the known info and that's that.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
As with blkid, having the standard usbmount directories in variables
makes use of these variables less error-prone on usage.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Using quotes and curly braces around shell variables everywhere can be
considered good programming practise andtends to be more consistent.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
It has a series of undefined behaviors related to quoting in POSIX.
It imposes a custom escaping mode with surprising results.
It's exceptionally hard to nest.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The blkid tool can output exactly what we need using various parameters.

This saves us some sed headaches. The only 'downside' is we can't use
our own names for the variables, which affects 'FSTYPE' so that was
renamed (rather then do a FSTYPE=$TYPE).

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Using egrep is considered deprecated and should be avoided and not used.
While we could use grep -q -E, using two simple string comparissions
avoid having to call an external tool, making the script lighter and
cleaner.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Use grep -E when quering fstab to avoid the deprecated egrep.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Parsing /proc/mounts by hand is not needed as we have the 'mountpoint'
utility (part of util-linux and busybox). This eases some regex foo
which improves readbility.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
While not strictly needed it is considered good practise to ensure proper exit
at the end of the script.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
By default, read will interpret backslashes before spaces and line feeds,
and otherwise strip them. This is rarely expected or desired.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The read utility reads multiple variables with a dummy variable called
'remainder'. Instead, use the more common and well recognized by checkers '_'
(underscore) as a dummy variable.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
When passing regex to grep, make this explicit with the -E parameter.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
With usbmount now being shellcheck compliant, there is only one
remaining warning, SC1091 about our sourced file.

While we cannot scan whatever the user has installed, we can point
shellcheck to the local default config instead.

Note, that this will still produce a warning on shellcheck.net as it
obviously still cannot access the file.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
@mathieulj
Copy link
Contributor

If your hoping to have these commits reviewed and merged within a reasonable time frame, I would suggest that you break them up into multiple pull requests as this list of commits is long enough to deter most people from taking the time to have a look.

@mathieulj
Copy link
Contributor

With that being said, I have given a quick look at the first few and they seem simple enough and well formatted so I'll probably be able to do a quick review. Unfortunately, I do not have commit access so I can merge myself but at least I can lessen the load of the primary maintainer.

@rbrito
Copy link
Owner

rbrito commented Oct 31, 2018 via email

@oliv3r
Copy link
Author

oliv3r commented Oct 31, 2018

ok with that being said, do note, i have not yet tested it!! (while i do not expect much from it, this is mostly cleanup work) I will be testing it in a VM shortly (I cannot do it on my current system easily as it will interfere with a lot of stuff.

Since I am going for LABEL support and 'runtime' directory creation and removal, I will be working on that as well.

As for the separate pull requests, I thought this was quite separated :) It is all neatly organized in commits, if you read it commit by commit, it becomes very easy and sensible I hope :)

But again, i can split it up in multiple PR if that helps the load or burden!

Olliver

@orel1
Copy link

orel1 commented Oct 31, 2018

Hello,
For the record, I started making changes in my corner on usbmount, which I discovered, after I started developing a similar project in bash...
The improvements/modifications I made are available on my own fork repo, everything is functional based on the tests I was able to perform. These modifications include in particular the support of mounting via the LABEL.
Unfortunately, I didn't take the time to finalize the work (merge) to send a pull request...
Feel free to include in your own code the parts that may be interesting.

@mathieulj
Copy link
Contributor

Those commits LGTM. Very nicely organised and explained. A real joy to review. I have yet to test it but I should be able to do so soon.

@oliv3r
Copy link
Author

oliv3r commented Nov 16, 2018

I have to admit I also still have failed to test it; so sorry for that, but hopefully soon; i just installed a KVM with debian in it and will start testing stuff; as I need it for the second series of patches I have planned :)

@nstrelow
Copy link

Is this gonna be merged in 2021 :D

Or are there any better alternatives to usbmount nowdays? :P

@andydvsn
Copy link

andydvsn commented Feb 8, 2022

I have merged all outstanding pull requests to a fork of this repo due to the death in April 2021 of @rbrito. RIP.

I have no particular experience with usbmount other than using it on one of my projects, so I'm probably not a good candidate to look to for ongoing work on the project. However, it's there (presently untested) if anybody needs it.

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.

None yet

6 participants