Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
SaswatPadhi committed Oct 2, 2024
1 parent b70efc6 commit dba43b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
39 changes: 17 additions & 22 deletions comp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2016,SC2034,SC2068,SC2154,SC2317 source=/dev/null
# shellcheck disable=SC2016,SC2154,SC2164,SC2317 source=/dev/null

set -Eumo pipefail

Expand Down Expand Up @@ -46,7 +46,9 @@ source "$SCRIPTS_DIR/colors.sh"

__append_env_from () {
if [ -f "$1" ] ; then
if ! ( set -a && source .env && "$1" ) >> .env ; then
if set -a && source .env && "$1" > .env.add ; then
cat .env.add >> .env ; rm .env.add
else
local script_file="${1/#./$comp}"
echo "'${script_file#"$SELF_DIR"/}' FAILED!" ; return 1
fi
Expand Down Expand Up @@ -257,8 +259,7 @@ do_validate () {
do_clean () {
__grab_ps __ps_before_clean
if [ -n "$__ps_before_clean" ] ; then
__error "Cannot clean while ${_bold_}$comp${_normal_} is running!"
return 1
__error "Cannot clean while ${_bold_}$comp${_normal_} is running!" ; return 1
fi

rm -rfv generated .env
Expand Down Expand Up @@ -304,8 +305,7 @@ do_status () {
for svc in $( "$YQ_CMD" -M '.services | keys | .[]' docker-compose.yml ) ; do
echo -n " $svc"
if ! ( echo "$__ps_before_status" | grep "$svc" | grep -q healthy ) ; then
echo ; __error "Unhealthy service: ${_fg_red_}$svc${_normal_}"
return 1
echo ; __error "Unhealthy service: ${_fg_red_}$svc${_normal_}" ; return 1
fi
done
echo
Expand Down Expand Up @@ -361,7 +361,6 @@ Compositions Found ($num_comps):" >&2
done <<< "$compositions" >&2
exit $EXIT_CODE_USAGE_ERROR
}

[ $# -gt 0 ] || usage

expand_verbs () {
Expand All @@ -382,16 +381,11 @@ expand_verbs () {
}

VERBS="${1//,/ }"
for VERB in $VERBS ; do
[ "$VERB" = "clean" ] || \
[ "$VERB" = "down" ] || \
[ "$VERB" = "overrides" ] || \
[ "$VERB" = "pull" ] || \
[ "$VERB" = "status" ] || \
[ "$VERB" = "up" ] || \
[ "$VERB" = "validate" ] || \
expand_verbs "$VERBS" || \
usage "Unknown verb: $VERB"
for V in $VERBS ; do
[ "$V" = "clean" ] || [ "$V" = "down" ] || [ "$V" = "overrides" ] || [ "$V" = "pull" ] \
|| [ "$V" = "status" ] || [ "$V" = "up" ] || [ "$V" = "validate" ] \
|| expand_verbs "$VERBS" \
|| usage "Unknown verb: $V"
done
shift

Expand All @@ -418,12 +412,13 @@ done
validate_and_set_option () {
local OPTION="OPTION_$2"
case "$1" in
yes | no ) printf -v "$OPTION" "%s" "$1"
return 0
yes | no ) printf -v "$OPTION" "%s" "$1" ; return 0
esac
[ "$3" = "override" ] \
&& ( echo ; __error "Invalid value '$1' for '${2,,}' option in options.override.conf" ) \
|| usage "Invalid value '$1' for '${2,,}' option"
if [ "$3" = "override" ] ; then
echo ; __error "Invalid value '$1' for '${2,,}' option in options.override.conf"
else
usage "Invalid value '$1' for '${2,,}' option"
fi
return 1
}

Expand Down
2 changes: 0 additions & 2 deletions pihole/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2.4"

networks:
default:
driver: bridge
Expand Down

0 comments on commit dba43b5

Please sign in to comment.