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
"$@"; }
31 # if [[ -e $f ]] && (( $(stat -c %Y $f) > $now - 60*60*24 )); then
34 if [[ $1 == -f ]]; then # f for fast
39 echo "error: unrecognized arguments" >&2
44 lnf
() { ln -sf "$@"; }
51 # If we make a link back to the root, we stop going deeper into subdir_files.
52 # This makes it so we can do subdir directories.
54 # Also note, under filesystem/, symlinks are expanded.
60 targets
=( "$2"/!(.git|..|.
) )
62 for f
in "$1"/!(.git|..|.
); do
63 if [[ -d $f ]]; then targets
+=("$f"); fi
67 below
="$( readlink -f "$root/..
")"
68 for path
in "${targets[@]}"; do
70 fullpath
="$(readlink -f "$path")"
71 #e $fullpath $below # debug
72 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
73 m lnf
-T "$path" "$HOME/${path#$root/}"
74 elif [[ -d "$path" ]]; then
75 subdir-link-r
"$root" "$path"
82 local dir fs x f systemd_reload
86 if [[ -e $fs && $user =~ ^iank?$
]]; then
87 # this could be done with rsync, something like this,
88 # but I haven't looked at the symlinks.
89 # s rsync -n -ahviSAXPH --specials --devices --chown=root:root --chmod=g-s $fs /
90 # note, symlinks get resolved, not copied.
92 --exclude etc
/dovecot
/users \
93 --exclude etc
/exim
4/passwd \
94 --exclude etc
/exim
4/*.pem \
95 --mode=g-s
--owner=0 --group=0 -cz -C $fs . | s
tar -dz -C / |
grep /etc
/systemd
&>/dev
/null
; then
100 if [[ -e $dir/subdir_files
]]; then
101 m subdir-link-r
$dir/subdir_files
103 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
104 (( ${#x[@]} >= 1 )) ||
continue
107 if $systemd_reload; then
108 m s systemctl daemon-reload
113 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
114 # note, we assume a group of hosts does not have the
115 # same name as a single host, which is no problem on our scale.
116 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
117 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
120 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
123 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
124 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
125 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
126 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
128 if [[ -e ${files[0]} ]]; then
129 chmod 600 ${files[@]}
131 # p needs to go first so .ssh link is created, then config link inside it
132 m common-file-setup
${all_dirs[@]}
134 #### begin special extra stuff ####
135 install -d -m700 ~
/gpg-agent-socket
139 # reset to the original permissions.
143 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
144 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
145 s chgrp www-data
/etc
/davpass
147 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
148 s chown
-R znc
:znc
/var
/lib
/znc
150 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
151 f
=/etc
/prometheus-htpasswd
153 s
chmod 640 $f /etc
/prometheus-pass
154 s chown root
:www-data
$f
155 if getent passwd prometheus
; then
156 s chown root
:prometheus
/etc
/prometheus-pass
160 ##### end special extra stuff #####
162 if [[ -e /etc
/openvpn
]]; then
163 sudo bash
-c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
166 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
168 f
=/a
/bin
/distro-setup
/system-status
172 echo 0 >~
/.local
/conflink
176 m common-file-setup
${c_dirs[@]}
179 echo "$0: error: unexpected user"; exit 1