minor bug fix and refactor
authorIan Kelling <ian@iankelling.org>
Thu, 3 Oct 2024 03:36:13 +0000 (23:36 -0400)
committerIan Kelling <ian@iankelling.org>
Thu, 3 Oct 2024 03:36:13 +0000 (23:36 -0400)
conflink

index 3714d9cd2eb0f3323dd8a0675c386e2c61acf0b0..5edc21e3eebfd8323f5fdd6ea86bc6fab33422a6 100755 (executable)
--- 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