From bb1b277db0f3ab996d579fcfb42cea4ec72b86d9 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Wed, 19 Jun 2019 19:06:16 +0200 Subject: Rename to "bosun" --- Makefile | 6 +++--- bosun | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bosun.1 | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rolectl | 74 --------------------------------------------------------------- rolectl.1 | 73 -------------------------------------------------------------- 5 files changed, 150 insertions(+), 150 deletions(-) create mode 100755 bosun create mode 100644 bosun.1 delete mode 100755 rolectl delete mode 100644 rolectl.1 diff --git a/Makefile b/Makefile index 0605b82..9f7fd55 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX ?= /usr/local -install: rolectl rolectl.1 - install -D -m 755 -t '${DESTDIR}${PREFIX}/bin' rolectl - install -D -m 644 -t '${DESTDIR}${PREFIX}/share/man/man1' rolectl.1 +install: bosun bosun.1 + install -D -m 755 -t '${DESTDIR}${PREFIX}/bin' bosun + install -D -m 644 -t '${DESTDIR}${PREFIX}/share/man/man1' bosun.1 .PHONY: install diff --git a/bosun b/bosun new file mode 100755 index 0000000..3351dbc --- /dev/null +++ b/bosun @@ -0,0 +1,74 @@ +#!/bin/sh + +STOW_DIR=/etc/portage/stow +TARGET=/etc/portage + +stowcmd="stow -d "$STOW_DIR" -t "$TARGET"" + +need_root() { + if test $(id -u) -ne 0; then + printf 'This action requires superuser access.\n' + exit 1 + fi +} + +add() { + need_root + $stowcmd -S "$@" +} + +remove() { + need_root + $stowcmd -D "$@" +} + +flush() { + need_root + list | xargs -- $stowcmd -D +} + +rebuild() { + need_root + list | xargs -- $stowcmd -R +} + +list() { + subcmd="$1" + shift + case $subcmd in + active) list_active;; + all) list_all;; + available) list_available;; + *) list_active;; + esac +} + +list_active() { + # XXX: -r for xargs is a GNU extension + find /etc/portage/ -lname "*stow/*" -print0 2>/dev/null \ + | xargs -r0 readlink \ + | sed 's:.*stow/\([^/]\+\)/.*:\1:' \ + | sort -u +} + +list_all() { + ls -1 "$STOW_DIR" +} + +list_available() { + tmp="$(mktemp)" || exit 1 + list_active > "$tmp" + list_all | comm -13 "$tmp" - + rm -f "$tmp" +} + +cmd="$1" +shift +case $cmd in + add) add "$@";; + flush) flush;; + list) list "$@";; + rebuild) rebuild;; + remove) remove "$@";; + *) list_active;; +esac diff --git a/bosun.1 b/bosun.1 new file mode 100644 index 0000000..cfe0a12 --- /dev/null +++ b/bosun.1 @@ -0,0 +1,73 @@ +.Dd June 19, 2019 +.Dt BOSUN 1 +.Os +.Sh NAME +.Nm bosun +.Nd manage portage roles with stow +.Sh SYNOPSIS +.Nm +.Op Ar command +.Sh DESCRIPTION +.Nm +is a program to add, remove, and list portage roles. +.Pp +A +.Dq role +is a directory comprised of a set of portage configuration files +pertaining to a specific service, usage, et cetera. +Roles are placed into +.Em /etc/portage/stow . +.Pp +.Nm +uses +.Xr stow 1 +to build a full set of portage configuration files in +.Em /etc/portage . +It does so by creating symlinks in +.Em /etc/portage +that point back to the actual files in the role directories. +.Pp +The commands are as follows: +.Bl -tag -width Ds +.It Sy add Em role +Activates the given role on the system. +.It Sy flush +Deactivates all actives roles on the system. +.It Sy list [ Em type ] +Lists roles of the given type. +If no type is given, list roles of the +.Dq active +type. +The types are as follows: +.Bl -tag -width Ds +.It Sy active +Lists roles that are active on the system. +.It Sy all +Lists all roles. +.It Sy available +Lists roles that not active on the system. +.El +.It Sy rebuild +Deactivates all active roles and then activates them again. +This is used to incorporate files that have been added to an already +active role. +.It Sy remove Em role +Deactivates the given role on the system. +.El +.Pp +If no command is given, +.Nm +will list active roles. +.Sh FILES +.Bl -tag -width Ds +.It Em /etc/portage/stow +The base directory containing all portage roles. +.El +.Sh SEE ALSO +.Xr stow 1 , +.Xr portage 5 +.Sh AUTHORS +.An -nosplit +.Nm +was written by +.An Wolfgang Müller Aq Mt vehk@vehk.de diff --git a/rolectl b/rolectl deleted file mode 100755 index 3351dbc..0000000 --- a/rolectl +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -STOW_DIR=/etc/portage/stow -TARGET=/etc/portage - -stowcmd="stow -d "$STOW_DIR" -t "$TARGET"" - -need_root() { - if test $(id -u) -ne 0; then - printf 'This action requires superuser access.\n' - exit 1 - fi -} - -add() { - need_root - $stowcmd -S "$@" -} - -remove() { - need_root - $stowcmd -D "$@" -} - -flush() { - need_root - list | xargs -- $stowcmd -D -} - -rebuild() { - need_root - list | xargs -- $stowcmd -R -} - -list() { - subcmd="$1" - shift - case $subcmd in - active) list_active;; - all) list_all;; - available) list_available;; - *) list_active;; - esac -} - -list_active() { - # XXX: -r for xargs is a GNU extension - find /etc/portage/ -lname "*stow/*" -print0 2>/dev/null \ - | xargs -r0 readlink \ - | sed 's:.*stow/\([^/]\+\)/.*:\1:' \ - | sort -u -} - -list_all() { - ls -1 "$STOW_DIR" -} - -list_available() { - tmp="$(mktemp)" || exit 1 - list_active > "$tmp" - list_all | comm -13 "$tmp" - - rm -f "$tmp" -} - -cmd="$1" -shift -case $cmd in - add) add "$@";; - flush) flush;; - list) list "$@";; - rebuild) rebuild;; - remove) remove "$@";; - *) list_active;; -esac diff --git a/rolectl.1 b/rolectl.1 deleted file mode 100644 index 2efc2a5..0000000 --- a/rolectl.1 +++ /dev/null @@ -1,73 +0,0 @@ -.Dd February 24, 2019 -.Dt ROLECTL 1 -.Os -.Sh NAME -.Nm rolectl -.Nd manage portage roles with stow -.Sh SYNOPSIS -.Nm -.Op Ar command -.Sh DESCRIPTION -.Nm -is a program to add, remove, and list portage roles. -.Pp -A -.Dq role -is a directory comprised of a set of portage configuration files -pertaining to a specific service, usage, et cetera. -Roles are placed into -.Em /etc/portage/stow . -.Pp -.Nm -uses -.Xr stow 1 -to build a full set of portage configuration files in -.Em /etc/portage . -It does so by creating symlinks in -.Em /etc/portage -that point back to the actual files in the role directories. -.Pp -The commands are as follows: -.Bl -tag -width Ds -.It Sy add Em role -Activates the given role on the system. -.It Sy flush -Deactivates all actives roles on the system. -.It Sy list [ Em type ] -Lists roles of the given type. -If no type is given, list roles of the -.Dq active -type. -The types are as follows: -.Bl -tag -width Ds -.It Sy active -Lists roles that are active on the system. -.It Sy all -Lists all roles. -.It Sy available -Lists roles that not active on the system. -.El -.It Sy rebuild -Deactivates all active roles and then activates them again. -This is used to incorporate files that have been added to an already -active role. -.It Sy remove Em role -Deactivates the given role on the system. -.El -.Pp -If no command is given, -.Nm -will list active roles. -.Sh FILES -.Bl -tag -width Ds -.It Em /etc/portage/stow -The base directory containing all portage roles. -.El -.Sh SEE ALSO -.Xr stow 1 , -.Xr portage 5 -.Sh AUTHORS -.An -nosplit -.Nm -was written by -.An Wolfgang Müller Aq Mt vehk@vehk.de -- cgit v1.2.3-2-gb3c3