X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=conflink;h=8deae093a7bbee829a72ab1cc590ed8a91390372;hb=a1ebefe19ab910d20fad0c2fd88637fee23dee7c;hp=0ae24c332cce236812b3d2521bd332edd8f96934;hpb=95a4248e98e118024f5065636288406e8e8c9a30;p=distro-setup diff --git a/conflink b/conflink index 0ae24c3..8deae09 100755 --- a/conflink +++ b/conflink @@ -1,7 +1,7 @@ #!/bin/bash source /a/bin/errhandle/err -_errcatch_cleanup() { +err-cleanup() { echo 1 >~/.local/conflink } @@ -24,14 +24,8 @@ m() { s() { sudo "$@"; } lnf() { /a/exe/lnf "$@"; } -now=$(date +%s) - -# error prone -#f=~/.local/conflink -# fast=false -# if [[ -e $f ]] && (( $(stat -c %Y $f) > $now - 60*60*24 )); then -# fast=true -# fi + +fast=false if [[ $1 == -f ]]; then # f for fast fast=true shift @@ -80,19 +74,35 @@ subdir-link-r() { common-file-setup() { - local dir fs x f systemd_reload - systemd_reload=false + local dir fs x f reload_systemd + local -a reload_services + local -a restart_services + reload_systemd=false for dir in "$@"; do fs=$dir/filesystem if [[ -e $fs && $user =~ ^iank?$ ]]; then - # this could be done with rsync, something like this, - # but I haven't looked at the symlinks. - # s rsync -n -ahviSAXPH --specials --devices --chown=root:root --chmod=g-s $fs / - # note, symlinks get resolved, not copied. - if s tar --mode=g-s --owner=0 --group=0 -cz -C $fs . | s tar -dz -C / | grep /etc/systemd &>/dev/null; then - systemd_reload=true - fi - s tar --mode=g-s --owner=0 --group=0 -cz -C $fs . | s tar -xz -C / + while read -r line; do + file="${line:12}" + case $file in + etc/systemd/system/*) + reload_systemd=true + ;; + etc/dnsmasq.d/*) + restart_services+=(dnsmasq) + ;; + esac + # Previously did this with tar, but it doesn't + # update directory permissions. + # + # S = do spare files efficiently + # A = preserve acls + # X = preserve extended attributes + # i = itemize + done < <(s rsync -aiSAX --chown=root:root --chmod=g-s \ + --exclude=/etc/dovecot/users \ + --exclude='/etc/exim4/passwd*' \ + --exclude='/etc/exim4/*.pem' \ + $fs/ /) fi if [[ -e $dir/subdir_files ]]; then @@ -102,9 +112,15 @@ common-file-setup() { (( ${#x[@]} >= 1 )) || continue m lnf ${x[@]} ~ done - if $systemd_reload; then + if $reload_systemd; then m s systemctl daemon-reload fi + for service in ${restart_services[@]}; do + if systemctl is-active $service >/dev/null; then + m s systemctl reload $service + fi + done + } user=$(id -un) @@ -167,6 +183,7 @@ case $user in if [[ -x $f ]]; then $f _ fi + mkdir -p ~/.local echo 0 >~/.local/conflink ;;