Package: linux-utils
The Python packagelinux-utilsprovides utility functions that make it easy
to script system administration tasks onLinuxsystems in Python. The
following functionality is currently implemented:Parsing of the/etc/fstaband/etc/crypttabconfiguration files.A basic Python API forcryptsetupand a Python implementation ofcryptdisks_startandcryptdisks_stop(with a command line interface).Atomic filesystem operations for Linux in Python.Simple network location awareness / discovery.The package is currently tested on cPython 2.7, 3.4, 3.5, 3.6, 3.7 and PyPy
(2.7) on Ubuntu Linux (usingTravis CI).InstallationUsagecryptdisks-start-fallbackcryptdisks-stop-fallbackHistoryContactLicenseInstallationThelinux-utilspackage is available onPyPIwhich means installation should
be as simple as:$pipinstalllinux-utilsThere’s actually a multitude of ways to install Python packages (e.g. theper
user site-packages directory,virtual environmentsor just installing
system wide) and I have no intention of getting into that discussion here, so
if this intimidates you then read up on your options before returning to these
instructions 😉.UsageFor details about the Python API please refer to the API documentation
available onRead the Docs. The Python implementation ofcryptdisks_startandcryptdisks_stopis available on the command line as the following two
programs:cryptdisks-start-fallbackcryptdisks-stop-fallbackAs the names imply these programs are not functional equivalents of their
“official” counterparts, because they only support LUKS encryption and a small
subset of the available encryption options.cryptdisks-start-fallbackUsage:cryptdisks-start-fallback NAMEReads /etc/crypttab and unlocks the encrypted filesystem with the given NAME.This program emulates the functionality of Debian’s cryptdisks_start program,
but it only supports LUKS encryption and a small subset of the available
encryption options.cryptdisks-stop-fallbackUsage:cryptdisks-stop-fallback NAMEReads /etc/crypttab and locks the encrypted filesystem with the given NAME.This program emulates the functionality of Debian’s cryptdisks_stop program,
but it only supports LUKS encryption and a small subset of the available
encryption options.HistoryBack in 2015 I wrote some Python code to parse the Linux configuration files/etc/fstaband/etc/crypttabfor use incrypto-drive-manager. Fast
forward to 2017 and I found myself wanting to use the same functionality
inrsync-system-backup. Three options presented themselves to me:Copy/paste the relevant codeHaving to maintain the same code in multiple places causes lower quality code
because having to duplicate the effort of writing documentation, developing
tests and fixing bugs is a very demotivating endeavor. In fact sometime in
2016 Ididcopy/paste parts of this code into a project at work, because I
needed similar functionality there. Of course since then the two
implementations have started diverging 😛.Make crypto-drive-manager a dependency of rsync-system-backupAlthough this approach is less ugly than copy/pasting the code, it still isn’t
exactly elegant because the two projects have nothing to do with each other
apart from working with LUKS encrypted disks on Linux.Extract the functionality into a new packageIn my opinion this is clearly the most elegant approach, unfortunately it also
requires the most work from me 😇. On the plus side I’m publishing the new
package with a test suite which means less untested code remains incrypto-drive-manager(which doesn’t have a test suite at the time of
writing).While extracting the code I shortly considered integrating the functionality
intodebuntu-tools, however the/etc/fstaband/etc/crypttabparsing
isn’t specific to Debian or Ubuntu at all anddebuntu-toolshas several
dependencies that aren’t relevant to Linux configuration file parsing.Since then it has become clear that this was a good choice (not merging the
functionality intodebuntu-tools) becauselinux-utilsnow provides a Python
implementation ofcryptdisks_startandcryptdisks_stop, which is mostly
useful on Linux systems thataren’tbased on Debian 🙂.ContactThe latest version oflinux-utilsis available onPyPIandGitHub. The
documentation is available onRead the Docsand includes achangelog. For
bug reports please create an issue onGitHub. If you have questions,
suggestions, etc. feel free to send me an e-mail atpeter@peterodding.com.LicenseThis software is licensed under theMIT license.© 2020 Peter Odding.