3 source /a
/bin
/errhandle
/err
8 Usage: ${0##*/} [OPTIONS]
9 Link or otherwise install configuration files.
11 -f For fast. Dont use lnf, use ln -sf. Good for updating existing files.
23 lnf
() { /a
/exe
/lnf
"$@"; }
24 if [[ $1 == -f ]]; then
25 lnf
() { ln -sf "$@"; }
32 # If we make a link back to the root, we stop going deeper into subdir_files.
33 # This makes it so we can do subdir directories.
35 # Also note, under filesystem/, symlinks are expanded.
41 targets
=( "$2"/!(.git|..|.
) )
43 for f
in "$1"/!(.git|..|.
); do
44 if [[ -d $f ]]; then targets
+=("$f"); fi
48 below
="$( readlink -f "$root/..
")"
49 for path
in "${targets[@]}"; do
51 fullpath
="$(readlink -f "$path")"
52 #e $fullpath $below # debug
53 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
54 m lnf
-T "$path" "$HOME/${path#$root/}"
55 elif [[ -d "$path" ]]; then
56 subdir-link-r
"$root" "$path"
67 if [[ -e $fs && $user =~ ^iank?$
]]; then
68 # note, symlinks get resolved, not copied.
69 s
tar --mode=g-s
--owner=0 --group=0 -cz -C $fs . | s
tar -xz -C /
72 if [[ -e $dir/subdir_files
]]; then
73 m subdir-link-r
$dir/subdir_files
75 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
76 (( ${#x[@]} >= 1 )) ||
continue
82 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
83 # note, we assume a group of hosts does not have the
84 # same name as a single host, which is no problem on our scale.
85 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
86 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
89 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
92 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
93 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
94 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
95 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
97 if [[ -e ${files[0]} ]]; then
100 # p needs to go first so .ssh link is created, then config link inside it
101 m common-file-setup
${all_dirs[@]}
103 #### begin special extra stuff ####
104 install -d -m700 ~
/gpg-agent-socket
108 # reset to the original permissions.
112 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
113 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
114 s chgrp www-data
/etc
/davpass
116 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
117 s chown
-R znc
:znc
/var
/lib
/znc
119 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
120 f
=/etc
/prometheus-htpasswd
122 s
chmod 640 $f /etc
/prometheus-pass
123 s chown root
:www-data
$f
124 if getent passwd prometheus
; then
125 s chown root
:prometheus
/etc
/prometheus-pass
129 ##### end special extra stuff #####
131 if [[ -e /etc
/openvpn
]]; then
132 sudo bash
-c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
135 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
138 m common-file-setup
${c_dirs[@]}
141 echo "$0: error: unexpected user"; exit 1