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
"$@"; }
27 if [[ $1 == -f ]]; then
28 lnf
() { ln -sf "$@"; }
35 # If we make a link back to the root, we stop going deeper into subdir_files.
36 # This makes it so we can do subdir directories.
38 # Also note, under filesystem/, symlinks are expanded.
44 targets
=( "$2"/!(.git|..|.
) )
46 for f
in "$1"/!(.git|..|.
); do
47 if [[ -d $f ]]; then targets
+=("$f"); fi
51 below
="$( readlink -f "$root/..
")"
52 for path
in "${targets[@]}"; do
54 fullpath
="$(readlink -f "$path")"
55 #e $fullpath $below # debug
56 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
57 m lnf
-T "$path" "$HOME/${path#$root/}"
58 elif [[ -d "$path" ]]; then
59 subdir-link-r
"$root" "$path"
70 if [[ -e $fs && $user =~ ^iank?$
]]; then
71 # note, symlinks get resolved, not copied.
72 s
tar --mode=g-s
--owner=0 --group=0 -cz -C $fs . | s
tar -xz -C /
75 if [[ -e $dir/subdir_files
]]; then
76 m subdir-link-r
$dir/subdir_files
78 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
79 (( ${#x[@]} >= 1 )) ||
continue
85 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
86 # note, we assume a group of hosts does not have the
87 # same name as a single host, which is no problem on our scale.
88 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
89 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
92 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
95 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
96 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
97 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
98 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
100 if [[ -e ${files[0]} ]]; then
101 chmod 600 ${files[@]}
103 # p needs to go first so .ssh link is created, then config link inside it
104 m common-file-setup
${all_dirs[@]}
106 #### begin special extra stuff ####
107 install -d -m700 ~
/gpg-agent-socket
111 # reset to the original permissions.
115 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
116 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
117 s chgrp www-data
/etc
/davpass
119 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
120 s chown
-R znc
:znc
/var
/lib
/znc
122 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
123 f
=/etc
/prometheus-htpasswd
125 s
chmod 640 $f /etc
/prometheus-pass
126 s chown root
:www-data
$f
127 if getent passwd prometheus
; then
128 s chown root
:prometheus
/etc
/prometheus-pass
132 ##### end special extra stuff #####
134 if [[ -e /etc
/openvpn
]]; then
135 sudo bash
-c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
138 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
141 m common-file-setup
${c_dirs[@]}
144 echo "$0: error: unexpected user"; exit 1
148 echo 0 >~
/.local
/conflink