Skip to content

Commit

Permalink
setup-dns: update for latest ecosystem and convention changes (#251)
Browse files Browse the repository at this point in the history
general fixes:

- [bash.bash: update for latest available bash version](f83d0f6)
- [`choose`: apply blockquote to linger results as well](4b6259d), /close  #252 
- `command-working`: added `trash` to exceptions
- `dorothy-workflow.yml`: add latest images, including macOS 15 / Sequoia
- [`get-macos-release-name`, `setup-util-(bash|gsed)`: support macOS Sequoia](6aed388)

general changes and improvements:

- `echo-mkdirp`: support quiet
- `eval-helper`: rewrote quiet/verbose handling and improved performance, added `--trim` option for use by `is-dns-working`, and renamed `--title=<title>` to `--command=<command-string>` used by `sudo-helper`
- `git-helper`, `setup-dns`: use `test ! -s <file>` instead of `test -z "$(cat <file>)"`
- `is-internet-working`: rewrote, with improved `--quiet` handling
- add `is-dns-working` to partner `is-internet-working`
- `service-helper`: rewrote where action invocation is now cycled by action provision, also fixed unloading
- `setup-environment-commands`: add `BIN_DIR`, `CONF_DIR`, `DATA_DIR`, `LIB_DIR`, `STATE_DIR`, `SERVICE_DIR`, `LOGS_DIR`
- `setup-mac-brew`: added a 'try again" note regarding upgrade failures
- `setup-util-plex` renamed to `setup-util-plex-media-server
- `setup-util`: add `--installed` and `--uninstalled` aliases
- `styles.bash`: add `code-good1` styles, add fragment styles

setup-dns changes and improvements:

- `setup-dns`: /close #221
    - made mono-function again, and cleaned up code
    - rewrote for modern conventions, fixed support of `adguard-home`, `dnscrypt-proxy`, and `cloudflared` on macos
    - now uses a new `dns.json` configuration for configuring services and providers, this adds descriptions for selection, and also added `dnscrypt_names` for quad9
- added `setup-util-(adguard-home|cloudflared|dnscrypt-proxy)` which are aliases for their `setup-dns` setups

todos:

- `setup-dns`:
    - consider a multi choose menu for `--install`/`--uninstall`/`--disable`
    - test on linux

commits:

- ad51e12
- 03c8de4
- 4b6259d
- 13b674a
- 6aed388
- f83d0f6
  • Loading branch information
balupton authored Sep 30, 2024
1 parent 3084bb4 commit d17514e
Show file tree
Hide file tree
Showing 24 changed files with 1,771 additions and 1,645 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runner: [ubuntu-24.04, ubuntu-22.04, macos-14, macos-12]
runner: [ubuntu-24.04, ubuntu-22.04, macos-15, macos-14, macos-12]
# ubuntu-20.04 not supported, echo-wait fails: https://github.com/bevry/dorothy/actions/runs/9705310169/job/26787151094#step:2:1346
runs-on: ${{ matrix.runner }}
steps:
Expand All @@ -131,7 +131,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runner: [macos-14, macos-12]
runner: [macos-15, macos-14, macos-12]
runs-on: ${{ matrix.runner }}
steps:
- name: 'Uninstall Homebrew'
Expand Down
10 changes: 6 additions & 4 deletions commands/choose
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ function choose_() (
load_dorothy_config 'styles.bash'

# refresh the styles
refresh_style_cache -- 'question_title_prompt' 'question_title_result' 'question_body' 'input_warning' 'input_error' 'icon_prompt' 'result_value' 'error' 'notice' 'count_spacer' 'result_line' 'active_line' 'selected_line' 'default_line' 'empty_line' 'inactive_line' 'legend' 'key' 'count_more' 'count_selected' 'count_defaults' 'count_empty' 'bar_top' 'bar_middle' 'bar_bottom' 'icon_multi_selected' 'icon_multi_default' 'icon_multi_active' 'icon_multi_standard' 'icon_single_selected' 'icon_single_default' 'icon_single_active_required' 'icon_single_active_optional' 'icon_single_standard' 'icon_nothing_provided' 'icon_no_selection' 'icon_nothing_selected' 'legend_legend_spacer' 'legend_key_spacer' 'key_key_spacer' 'indent_bar' 'indent_active' 'indent_inactive' 'indent_subsequent' 'nocolor__count_spacer' 'color__count_spacer'
refresh_style_cache -- 'question_title_prompt' 'question_title_result' 'question_body' 'input_warning' 'input_error' 'icon_prompt' 'result_value' 'error' 'notice' 'count_spacer' 'result_line' 'active_line' 'selected_line' 'default_line' 'empty_line' 'inactive_line' 'legend' 'key' 'count_more' 'count_selected' 'count_defaults' 'count_empty' 'bar_top' 'bar_middle' 'bar_bottom' 'icon_multi_selected' 'icon_multi_default' 'icon_multi_active' 'icon_multi_standard' 'icon_single_selected' 'icon_single_default' 'icon_single_active_required' 'icon_single_active_optional' 'icon_single_standard' 'icon_nothing_provided' 'icon_no_selection' 'icon_nothing_selected' 'legend_legend_spacer' 'legend_key_spacer' 'key_key_spacer' 'indent_bar' 'indent_active' 'indent_inactive' 'blockquote' 'nocolor__count_spacer' 'color__count_spacer'

# select icons
if test "$option_multi" = 'yes'; then
Expand Down Expand Up @@ -1495,7 +1495,7 @@ function choose_() (
else
# need to format item, as it is too big
item_rendered="$item_original"
item_rendered="${item_rendered//$'\n'/$'\n'"$style__indent_subsequent"}" # re-add the necessary indentation
item_rendered="${item_rendered//$'\n'/$'\n'"${style__indent_bar}${style__blockquote}"}" # re-add the necessary indentation
item_rendered="$(echo-wrap --width="$content_columns" -- "$item_rendered")"
item_rows="$(echo-count-lines -- "$item_rendered")"
items_renders[item_index]="$item_rendered"
Expand Down Expand Up @@ -1755,7 +1755,7 @@ function choose_() (
fi
}
function render_result {
local render="$question_title_result" index
local render="$question_title_result" index item item_rendered
if test -n "$commentary"; then
if test -n "$render"; then
render+=" $commentary"
Expand All @@ -1772,7 +1772,9 @@ function choose_() (
# add results only if lingering, as there may be more than terminal height, so clearing wouldn't support such
for index in "${selected_indexes[@]}"; do
if test "${selected[index]}" = 'yes'; then
render+="${style__result_line}${style__icon_selected}${items[index]}${style__end__result_line}"$'\n'
item="${items[index]}"
item_rendered="${item//$'\n'/$'\n'"$style__blockquote"}" # re-add the necessary indentation
render+="${style__result_line}${style__icon_selected}${item_rendered}${style__end__result_line}"$'\n'
fi
done
if test "$selected_count" -eq 0; then
Expand Down
2 changes: 2 additions & 0 deletions commands/command-working
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function command_working() (
# =====================================
# Helpers

# exceptions are all commands that do not respond to a version or help query
# https://github.com/greymd/teip/issues/29
# https://trunkcommunity.slack.com/archives/C0205B6KK8X/p1661601215325159
local failures=() exceptions=(
Expand All @@ -66,6 +67,7 @@ function command_working() (
ssh-askpass
sshd
teip
trash
trunk
)
function check_status {
Expand Down
27 changes: 13 additions & 14 deletions commands/echo-mkdir
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ function echo_mkdir() (
}

# process our own arguments, delegate everything else to stdinargs
local item option_sudo='no' option_args=()
local item option_sudo='no' option_args=() option_quiet
option_quiet="$(echo-quiet-enabled -- "$@")"
while test "$#" -ne 0; do
item="$1"
shift
case "$item" in
'--help' | '-h') help ;;
'--no-quiet'* | '--quiet'* | '--no-verbose'* | '--verbose'*) ;; # handled by echo-quiet-enabled
'--no-sudo'* | '--sudo'*)
option_sudo="$(get-flag-value --affirmative --fallback="$option_sudo" -- "$item")"
;;
Expand All @@ -56,27 +58,24 @@ function echo_mkdir() (
done

# construct command
local cmd=()
if test "$option_sudo" = 'yes'; then
cmd=(
'sudo-helper'
'--'
'mkdir'
'-p'
)
function __mkdir {
sudo-helper --reason="Your sudo/root/login password is required to make the directory: $*" -- mkdir -p "$@"
}
else
cmd=(
'mkdir'
'-p'
)
function __mkdir {
mkdir -p
}
fi

# =====================================
# Action

function on_line {
if test -d "$1" || ("${cmd[@]}" "$1"); then
fs-absolute -- "$1"
if test -d "$1" || __mkdir "$1"; then
if test "$option_quiet" != 'yes'; then
fs-absolute -- "$1"
fi
return 0
else
return 1
Expand Down
Loading

0 comments on commit d17514e

Please sign in to comment.