From 430e07e114abd191cb6748f7e0dab308eac9f30a Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 2 Oct 2024 23:36:13 -0400 Subject: [PATCH] minor bug fix and refactor --- conflink | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/conflink b/conflink index 3714d9c..5edc21e 100755 --- a/conflink +++ b/conflink @@ -45,10 +45,15 @@ EOF exit $1 } - +# maybe verbose m() { - "$@" + local out + out=$("$@" 2>&1) + if [[ $out ]]; then + printf "output of: %s\n%s\n" "$*" "$out" + fi } +# verbose v() { echo "$*" "$@" @@ -88,10 +93,9 @@ subdir-link-r() { common-file-setup() { - local dir fs f reload_systemd + local dir fs f local -a link_glob local -A restart_services - reload_systemd=false for dir in "$@"; do @@ -193,7 +197,7 @@ c_dirs=(/a/c{,/machine_specific/$HOSTNAME}) case $user in iank) - + reload_systemd=false old-files-cleanup /a/bin/ds/install-my-scripts @@ -240,8 +244,11 @@ case $user in --exclude='/etc/exim4/passwd*' --exclude='/etc/exim4/*.pem' ${rsync_args[@]} / ) - echo "${cmd[@]@Q}" - "${cmd[@]}" | tee $tmpf + "${cmd[@]}" >$tmpf + if [[ -s $tmpf ]]; then + printf "output of: %s\n" "${cmd[*]}" + cat $tmpf + fi while read -r line; do file="${line:12}" @@ -288,19 +295,19 @@ case $user in if [[ -e /p/c/user-specific/prometheus ]]; then if getent passwd prometheus &>/dev/null; then - v rsync -clpgoDiSAX --chmod=g+r --chown=root:prometheus /p/c/user-specific/prometheus/prometheus-pass /etc - v rsync -clpgoDiSAX --chmod=g+r --chown=root:prometheus /p/c/user-specific/prometheus/prometheus/ssl/* /etc/prometheus/ssl + m rsync -clpgoDiSAX --chmod=g+r --chown=root:prometheus /p/c/user-specific/prometheus/prometheus-pass /etc + m rsync -clpgoDiSAX --chmod=g+r --chown=root:prometheus /p/c/user-specific/prometheus/prometheus/ssl/* /etc/prometheus/ssl fi fi if [[ -e /p/c/user-specific/www-data ]]; then if getent passwd www-data &>/dev/null; then - v rsync -clpgoDiSAX --chmod=g+r --chown=root:www-data /p/c/user-specific/www-data/* /etc + m rsync -clpgoDiSAX --chmod=g+r --chown=root:www-data /p/c/user-specific/www-data/* /etc fi fi if [[ -e /p/c/user-specific/znc ]]; then if getent group znc &>/dev/null; then - v rsync -rclpgoDiSAX --chown=znc:znc /p/c/user-specific/znc/ /var/lib/znc + m rsync -rclpgoDiSAX --chown=znc:znc /p/c/user-specific/znc/ /var/lib/znc fi fi @@ -311,14 +318,14 @@ case $user in # "var/lib/bind/dsset-*" if [[ -e /p/c/user-specific/bind ]]; then if getent group bind &>/dev/null; then - v rsync -clpgoDiSAX --chmod=g+r --chown=root:bind /p/c/user-specific/bind/etc/bind/* /etc/bind - v rsync -clpgoDiSAX --chmod=g+r --chown=root:bind /p/c/user-specific/bind/var/lib/bind/* /var/lib/bind + m rsync -clpgoDiSAX --chmod=g+r --chown=root:bind /p/c/user-specific/bind/etc/bind/* /etc/bind + m rsync -clpgoDiSAX --chmod=g+r --chown=root:bind /p/c/user-specific/bind/var/lib/bind/* /var/lib/bind fi fi # this folder strangely requires ownership as icecast2 (and icecast2 group is icecast without the 2). if [[ -d /etc/icecast2 && -e /p/c/user-specific/icecast ]]; then - v rsync -clgoDiSAX --chmod=g+r --chown=root:icecast /p/c/user-specific/icecast2/icecast.xml /etc/icecast2 + m rsync -clgoDiSAX --chmod=g+r --chown=root:icecast /p/c/user-specific/icecast2/icecast.xml /etc/icecast2 fi # disabled -- 2.30.2