3 source /a
/bin
/errhandle
/err
10 lnf
() { /a
/exe
/lnf
"$@"; }
14 shopt -s extglob
# note, already set with bash -l
16 # If we make a link back to the root, we stop going deeper into subdir_files.
17 # This makes it so we can do subdir directories.
19 # Also note, under filesystem/, symlinks are expanded.
25 targets
=( "$2"/!(.git|..|.
) )
27 for f
in "$1"/!(.git|..|.
); do
28 [[ -d $f ]] && targets
+=("$f") ||
:
31 local below
="$( readlink -f "$root/..
")"
32 for path
in "${targets[@]}"; do
33 local fullpath
="$(readlink -f "$path")"
34 #e $fullpath $below # debug
35 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
36 m lnf
-T "$path" "$HOME/${path#$root/}"
37 elif [[ -d "$path" ]]; then
38 subdir-link-r
"$root" "$path"
46 local dir fs x bdir f dst
49 if [[ -e $fs && $USER =~ ^iank?$
]]; then
50 # note, symlinks get resolved, not copied.
51 s
tar --mode=g-s
--owner=0 --group=0 -cz -C $fs . | s
tar -xz -C /
54 if [[ -e $dir/subdir_files
]]; then
55 m subdir-link-r
$dir/subdir_files
57 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
58 (( ${#x[@]} >= 1 )) ||
continue
63 all_dirs
=({/a
/c
,/p
/c
}{,/machine_specific
/$HOSTNAME})
64 # note, we assume a group of hosts does not have the
65 # same name as a single host, which is no problem on our scale.
66 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
67 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
70 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
73 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
74 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
75 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
76 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
78 if [[ -e $files ]]; then
81 # p needs to go first so .ssh link is created, then config link inside it
82 m common-file-setup
${all_dirs[@]}
84 #### begin special extra stuff ####
85 install -d -m700 ~
/gpg-agent-socket
89 # reset to the original permissions.
93 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
94 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
95 s chgrp www-data
/etc
/davpass
97 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
98 s chown
-R znc
:znc
/var
/lib
/znc
100 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
101 f
=/etc
/prometheus-htpasswd
103 s
chmod 640 $f /etc
/prometheus-pass
104 s chown root
:www-data
$f
105 if getent passwd prometheus
; then
106 s chown root
:prometheus
/etc
/prometheus-pass
110 ##### end special extra stuff #####
112 sudo bash
-c 'shopt -s nullglob; cd /etc/openvpn; for f in client/* server/*; do ln -sf $f .; done'
114 m sudo
-H -u traci
"$BASH_SOURCE"
117 m common-file-setup
${c_dirs[@]}
120 echo "$0: error: unexpected user"; exit 1