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
)
94 # Previously did this with tar, but it doesn't
95 # update directory permissions.
97 # S = do spare files efficiently
99 # X = preserve extended attributes
101 done < <(s rsync
-aiSAX --chown=root
:root
--chmod=g-s \
102 --exclude=/etc
/dovecot
/users \
103 --exclude='/etc/exim4/passwd*' \
104 --exclude='/etc/exim4/*.pem' \
108 if [[ -e $dir/subdir_files
]]; then
109 m subdir-link-r
$dir/subdir_files
111 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
112 (( ${#x[@]} >= 1 )) ||
continue
115 if $reload_systemd; then
116 m s systemctl daemon-reload
118 for service
in ${restart_services[@]}; do
119 if systemctl is-active
$service >/dev
/null
; then
120 m s systemctl reload
$service
127 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
128 # note, we assume a group of hosts does not have the
129 # same name as a single host, which is no problem on our scale.
130 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
131 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
134 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
137 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
138 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
139 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
140 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
142 if [[ -e ${files[0]} ]]; then
143 chmod 600 ${files[@]}
145 # p needs to go first so .ssh link is created, then config link inside it
146 m common-file-setup
${all_dirs[@]}
148 #### begin special extra stuff ####
149 install -d -m700 ~
/gpg-agent-socket
153 # reset to the original permissions.
157 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
158 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
159 s chgrp www-data
/etc
/davpass
161 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
162 s chown
-R znc
:znc
/var
/lib
/znc
164 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
165 f
=/etc
/prometheus-htpasswd
167 s
chmod 640 $f /etc
/prometheus-pass
168 s chown root
:www-data
$f
169 if getent passwd prometheus
; then
170 s chown root
:prometheus
/etc
/prometheus-pass
174 ##### end special extra stuff #####
176 if [[ -e /etc
/openvpn
]]; then
177 sudo bash
-c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
180 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
182 f
=/a
/bin
/distro-setup
/system-status
187 echo 0 >~
/.local
/conflink
191 m common-file-setup
${c_dirs[@]}
194 echo "$0: error: unexpected user"; exit 1