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. eg
48 # /p/c/subdir_files/.config/gajim -> ../../gagim
50 # Also note, under filesystem/, symlinks are expanded.
56 targets
=( "$2"/!(.git|..|.|.
#*) )
58 for f
in "$1"/!(.git|..|.|.
#*); do
59 if [[ -d $f ]]; then targets
+=("$f"); fi
63 below
="$( readlink -f "$root/..
")"
64 for path
in "${targets[@]}"; do
66 fullpath
="$(readlink -f "$path")"
67 if [[ -f $path || $
(dirname "$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 # we dont want t, instead c for checksum.
85 # That way we dont set times on directories.
87 cmd
=( s rsync
-rclpgoDiSAX --chown=root
:root
--chmod=g-s
88 --exclude=/etc
/dovecot
/users
89 --exclude='/etc/exim4/passwd*'
90 --exclude='/etc/exim4/*.pem'
93 while read -r line
; do
96 etc
/prometheus
/rules
/iank.yml
)
99 if systemctl is-active prometheus
&>/dev
/null
; then
100 m s systemctl reload prometheus
105 etc
/systemd
/system
/*)
109 restart_services
+=(dnsmasq
)
111 etc
/systemd
/resolved.conf.d
/*)
112 restart_services
+=(systemd-resolved
)
115 # Previously did this with tar, but it doesn't
116 # update directory permissions.
118 # S = do spare files efficiently
120 # X = preserve extended attributes
122 done < <("${cmd[@]}")
125 if ! $fast && [[ -e $dir/subdir_files
]]; then
126 m subdir-link-r
$dir/subdir_files
128 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.|.
#*) )
129 (( ${#x[@]} >= 1 )) ||
continue
132 if $reload_systemd; then
133 m s systemctl daemon-reload
135 for service
in ${restart_services[@]}; do
136 if systemctl is-active
$service >/dev
/null
; then
137 m s systemctl restart
$service
143 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
144 # note, we assume a group of hosts does not have the
145 # same name as a single host, which is no problem on our scale.
146 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
147 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
151 for t
in systemstatus epanicclean btrfsmaintstop dynamicipupdate
; do
152 f
=/etc
/systemd
/system
/$t.timer
154 s systemctl stop
$t.timer
155 s systemctl disable
$t.timer
161 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
164 /a
/bin
/ds
/install-my-scripts
165 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
166 /p
/c
/machine_specific
/*/filesystem
/etc
/openvpn
/client
/*.key
167 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
168 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
170 if [[ -e ${files[0]} ]]; then
171 chmod 600 ${files[@]}
173 # p needs to go first so .ssh link is created, then config link inside it
174 m common-file-setup
${all_dirs[@]}
176 #### begin special extra stuff ####
177 install -d -m700 ~
/gpg-agent-socket
181 # reset to the original permissions.
185 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
186 if [[ -e /etc
/caldav-htpasswd
]] && getent group www-data
&>/dev
/null
; then
187 s chgrp www-data
/etc
/caldav-htpasswd
189 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
190 s chown
-R znc
:znc
/var
/lib
/znc
192 for f
in /etc
/prometheus-
{,export-
}htpasswd
; do
195 if getent passwd www-data
&>/dev
/null
; then
196 s chown root
:www-data
$f
200 f
=/etc
/prometheus-pass
202 # note: this is duplicative of the file's own permissions
203 s
chmod 640 $f /etc
/prometheus-pass
204 if getent passwd prometheus
&>/dev
/null
; then
205 s chown root
:prometheus
$f
208 ##### end special extra stuff #####
211 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
214 f
=/a
/bin
/distro-setup
/system-status
219 echo 0 >~
/.local
/conflink
223 m common-file-setup
${c_dirs[@]}
226 echo "$0: error: unexpected user"; exit 1