aboutsummaryrefslogtreecommitdiffstats
path: root/bosun (unfollow)
Commit message (Collapse)AuthorLines
2021-03-10Have find look in the current directory explicitlyWolfgang Müller-1/+1
This will squash shellcheck's SC2184 [1]. [1] https://github.com/koalaman/shellcheck/wiki/SC2185
2021-03-10Allow overriding the role directoryWolfgang Müller-1/+1
The upcoming test suite needs a way to operate on roles without referencing the system's default store in /etc/portage/stow. Have bosun respect the 'BOSUN_DIR' environment variable that overrides the role directory bosun operates on.
2021-03-10Improve and harden list_activeWolfgang Müller-7/+8
An upcoming commit will introduce support for the BOSUN_DIR environment variable that allows users (and, crucially, the upcoming test suite) to override the default role directory. Since we have previously assumed that we are in full control of STOW_DIR, we now have to be more careful. Revamp list_active such that the sed invocation no longer gets any user input. This should protect against any nefarious contents in BOSUN_DIR. The new approach used by list_active relies on 'realpath', a GNU-only coreutils program, and its '--relative-base' option which prints absolute paths unless they are below a given directory. This allows us to filter symbolic links that do not point to a path within BOSUN_DIR.
2021-03-10Do not act if there is nothing to flush or rebuildWolfgang Müller-2/+2
By default, xargs runs the given command once even if there is no input. This does not make sense for these two invocations, so make sure that xargs only runs if active roles were found. Furthermore, state explicitly which command to run and do not rely on the default action of 'list'. Note: This change makes use of the '-r' flag, which is a GNU extension. We assume that bosun is only ever going to be used on Gentoo systems, so this should be fine.
2021-03-10Remove the test for superuser accessWolfgang Müller-8/+0
As bosun may run in environments that do not require superuser access, do away with this check and rely on stow itself for any relevant error reporting. This will also enable an upcoming test suite to work correctly.
2020-05-13Add aliases for the `remove` commandWynn Wolf Arbor-1/+1
Even if the user is familiar with bosun(1), they might try to remove a role by invoking it with `delete` or `del` instead of `remove`. As these are very common synonyms, add a simple DWIM mechanic to enhance the user experience.
2020-05-13Improve error reportingWynn Wolf Arbor-4/+31
This commit introduces several improvements to the way bosun reacts to and reports errors. Instead of doing nothing and exiting silently, alert the user and print a short usage synopsis if bosun does not understand a command it was passed. Also, alert the user and print available list types if the `list` command was invoked with a type it does not understand. Lastly, check for the existence of a role before trying to `add`, `remove`, or `rebuild` it.
2020-05-13Simplify handling of default actionsWynn Wolf Arbor-4/+2
Instead of using a catchall pattern for `case`, assign a default value to the variable in question. This helps reduce the amount of special cases - especially considering the addition of better error reporting in an upcoming commit.
2020-05-13Only shift positional parameters if there are anyWynn Wolf Arbor-2/+1
bash 5.0 now enables its 'shift_verbose' option in POSIX mode by default, printing an error message if there's not enough positional arguments for the `shift` builtin. We rely on the previous (silent) behaviour in two places. For main command parsing, introduce an explicit check before invoking `shift` to make sure it is only called if there are enough positional arguments. The call to `shift` in the list() method is actually superfluous, as no more than one positional argument is ever referenced; we drop it fully there.
2020-01-21Make list_active more robustWynn Wolf Arbor-5/+6
A couple of small changes to this function should make it more robust in the long run: 1) We no longer filter the symlinks with find(1), instead combining filtering and substituting in sed(1) 2) We use the absolute path (as given by readlink -f) such that we can anchor the regular expression pattern to avoid unwanted substitution. 3) Instead of hard-coding paths we now use STOW_DIR (and STOW_DIR/.. for the target directory) 4) To avoid unnecessary complexity, we no longer let the user override STOW_DIR. This tool is supposed to be used with the canonical /etc/portage/stow location
2020-01-20Have rebuild accept one or more rolesWynn Wolf Arbor-2/+6
This lets the user rebuild (or restow) specific roles and will fix a certain issue with stow refusing to unstow everything.
2020-01-20Make shellcheck happyWynn Wolf Arbor-1/+1
I would not expect this to ever fail, but quoting the specific invocation of id -u here silences the only shellcheck warning.
2020-01-20Simplify invocation of stowWynn Wolf Arbor-8/+6
Instead of hard-coding the stow invocation (which also had a quoting issue), just export the STOW_DIR environment variable which stow uses already. TARGET can be dropped because it is implicitly defined to be the parent directory of STOW_DIR.
2019-06-19Rename to "bosun"1.0.0Wolfgang Müller-0/+0