3 source /a
/bin
/errhandle
/err
5 echo 1 >~
/.local
/conflink
11 Usage: ${0##*/} [OPTIONS]
12 Link or otherwise install configuration files.
14 -f For fast. Dont use lnf, use ln -sf. Good for updating existing files.
26 lnf
() { /a
/exe
/lnf
"$@"; }
29 if [[ $1 == -f ]]; then # f for fast
34 echo "error: unrecognized arguments" >&2
39 lnf
() { ln -sf "$@"; }
46 # If we make a link back to the root, we stop going deeper into subdir_files.
47 # This makes it so we can do subdir directories.
49 # Also note, under filesystem/, symlinks are expanded.
55 targets
=( "$2"/!(.git|..|.
) )
57 for f
in "$1"/!(.git|..|.
); do
58 if [[ -d $f ]]; then targets
+=("$f"); fi
62 below
="$( readlink -f "$root/..
")"
63 for path
in "${targets[@]}"; do
65 fullpath
="$(readlink -f "$path")"
66 #e $fullpath $below # debug
67 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
68 m lnf
-T "$path" "$HOME/${path#$root/}"
69 elif [[ -d "$path" ]]; then
70 subdir-link-r
"$root" "$path"
77 local dir fs x f reload_systemd
78 local -a reload_services
79 local -a restart_services
83 if [[ -e $fs && $user =~ ^iank?$
]]; then
84 while read -r line
; do
91 restart_services
+=(dnsmasq
)
93 etc
/systemd
/resolved.conf.d
/*)
94 restart_services
+=(systemd-resolved
)
97 # Previously did this with tar, but it doesn't
98 # update directory permissions.
100 # S = do spare files efficiently
102 # X = preserve extended attributes
104 done < <(s rsync
-aiSAX --chown=root
:root
--chmod=g-s \
105 --exclude=/etc
/dovecot
/users \
106 --exclude='/etc/exim4/passwd*' \
107 --exclude='/etc/exim4/*.pem' \
111 if [[ -e $dir/subdir_files
]]; then
112 m subdir-link-r
$dir/subdir_files
114 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
115 (( ${#x[@]} >= 1 )) ||
continue
118 if $reload_systemd; then
119 m s systemctl daemon-reload
121 for service
in ${restart_services[@]}; do
122 if systemctl is-active
$service >/dev
/null
; then
123 m s systemctl restart
$service
130 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
131 # note, we assume a group of hosts does not have the
132 # same name as a single host, which is no problem on our scale.
133 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
134 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
137 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
140 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
141 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
142 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
143 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
145 if [[ -e ${files[0]} ]]; then
146 chmod 600 ${files[@]}
148 # p needs to go first so .ssh link is created, then config link inside it
149 m common-file-setup
${all_dirs[@]}
151 #### begin special extra stuff ####
152 install -d -m700 ~
/gpg-agent-socket
156 # reset to the original permissions.
160 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
161 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
162 s chgrp www-data
/etc
/davpass
164 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
165 s chown
-R znc
:znc
/var
/lib
/znc
167 f
=/etc
/prometheus-htpasswd
169 s
chmod 640 $f /etc
/prometheus-pass
170 s chown root
:www-data
$f
171 if getent passwd prometheus
; then
172 s chown root
:prometheus
/etc
/prometheus-pass
176 ##### end special extra stuff #####
178 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
180 f
=/a
/bin
/distro-setup
/system-status
185 echo 0 >~
/.local
/conflink
189 m common-file-setup
${c_dirs[@]}
192 echo "$0: error: unexpected user"; exit 1