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 # f for fast
28 lnf
() { ln -sf "$@"; }
31 echo "error: unrecognized arguments" >&2
39 # If we make a link back to the root, we stop going deeper into subdir_files.
40 # This makes it so we can do subdir directories.
42 # Also note, under filesystem/, symlinks are expanded.
48 targets
=( "$2"/!(.git|..|.
) )
50 for f
in "$1"/!(.git|..|.
); do
51 if [[ -d $f ]]; then targets
+=("$f"); fi
55 below
="$( readlink -f "$root/..
")"
56 for path
in "${targets[@]}"; do
58 fullpath
="$(readlink -f "$path")"
59 #e $fullpath $below # debug
60 if [[ -f $path || $
(dirname $
(readlink
-f "$fullpath")) == "$below" ]]; then
61 m lnf
-T "$path" "$HOME/${path#$root/}"
62 elif [[ -d "$path" ]]; then
63 subdir-link-r
"$root" "$path"
74 if [[ -e $fs && $user =~ ^iank?$
]]; then
75 # note, symlinks get resolved, not copied.
76 s
tar --mode=g-s
--owner=0 --group=0 -cz -C $fs . | s
tar -xz -C /
79 if [[ -e $dir/subdir_files
]]; then
80 m subdir-link-r
$dir/subdir_files
82 local x
=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.
) )
83 (( ${#x[@]} >= 1 )) ||
continue
89 all_dirs
=({/a
/bin
/ds
,/p
/c
}{,/machine_specific
/$HOSTNAME})
90 # note, we assume a group of hosts does not have the
91 # same name as a single host, which is no problem on our scale.
92 for x
in /p
/c
/machine_specific
/*.hosts
/a
/bin
/ds
/machine_specific
/*.hosts
; do
93 if grep -qxF $HOSTNAME $x; then all_dirs
+=( ${x%.hosts} ); fi
96 c_dirs
=(/a
/c
{,/machine_specific
/$HOSTNAME})
99 files
=(/p
/c
/machine_specific
/*/filesystem
/etc
/ssh
/*_key
100 /p
/c
/filesystem
/etc
/openvpn
/client
/*.key
101 /p
/c
/filesystem
/etc
/openvpn
/easy-rsa
/keys
/*.key
102 /p
/c
/machine_specific
/kw
/filesystem
/etc
/openvpn
/client
/*.key
104 if [[ -e ${files[0]} ]]; then
105 chmod 600 ${files[@]}
107 # p needs to go first so .ssh link is created, then config link inside it
108 m common-file-setup
${all_dirs[@]}
110 #### begin special extra stuff ####
111 install -d -m700 ~
/gpg-agent-socket
115 # reset to the original permissions.
119 sudo bash
-c 'shopt -s nullglob; for f in /etc/bind/*.key /etc/bind/*.private /etc/bind/key.*; do chgrp bind $f; done'
120 if [[ -e /etc
/davpass
]] && getent group www-data
&>/dev
/null
; then
121 s chgrp www-data
/etc
/davpass
123 if [[ -e /var
/lib
/znc
]] && getent group znc
; then
124 s chown
-R znc
:znc
/var
/lib
/znc
126 /a
/exe
/lnf
-T /p
/arbtt-capture.log ~
/.arbtt
/capture.log
127 f
=/etc
/prometheus-htpasswd
129 s
chmod 640 $f /etc
/prometheus-pass
130 s chown root
:www-data
$f
131 if getent passwd prometheus
; then
132 s chown root
:prometheus
/etc
/prometheus-pass
136 ##### end special extra stuff #####
138 if [[ -e /etc
/openvpn
]]; then
139 sudo bash
-c 'shopt -s nullglob && cd /etc/openvpn && for f in client/* server/*; do ln -sf $f .; done'
142 m sudo
-H -u user2
"${BASH_SOURCE[0]}"
145 m common-file-setup
${c_dirs[@]}
148 echo "$0: error: unexpected user"; exit 1
152 f
=/a
/bin
/distro-setup
/system-status
156 echo 0 >~
/.local
/conflink