#!/bin/bash
source /a/bin/errhandle/err
-_errcatch_cleanup() {
+err-cleanup() {
echo 1 >~/.local/conflink
}
lnf() { /a/exe/lnf "$@"; }
-# 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
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 --anchored \
- --exclude etc/dovecot/users \
- --exclude etc/exim4/passwd \
- --exclude etc/exim4/*.pem \
- --mode=g-s --owner=0 --group=0 -cz -C $fs . | s tar -dz -C / | grep /etc/systemd &>/dev/null; then
- systemd_reload=true
- fi
+ 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
(( ${#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)
##### end special extra stuff #####
- if [[ -e /etc/openvpn ]]; then
- sudo bash -c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
- fi
-
m sudo -H -u user2 "${BASH_SOURCE[0]}"
f=/a/bin/distro-setup/system-status
if [[ -x $f ]]; then
$f _
fi
+ mkdir -p ~/.local
echo 0 >~/.local/conflink
;;