-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_remote.sh
executable file
·54 lines (51 loc) · 1018 Bytes
/
install_remote.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -e
DOT="${DOT:-"${HOME}/.dotfiles"}"
TMP="${DOT}/tmp"
declare -a hosts
declare -a opts
port=22
remoteOpts=
while [[ -n "$1" ]]; do
case "$1" in
-h)
cat <<- 'EOF'
Usage:
$0 [-u USER] [-g GROUP] [-i ssh_privkey_file] \
[(-p|-P) ssh_port] [-o ssh_option] host...\
use -u and -g to specify USER and GROUP on target host
use -e to install exa, -l to install lsd
EOF
exit 0
;;
-p|-P)
port="$2"
shift
;;
-i|-o)
opts+=("$1" "$2")
shift
;;
-u|-g)
remoteOpts="${remoteOpts} '$1' '$2'"
shift
;;
-e|-l)
remoteOpts="${remoteOpts} '$1'"
;;
-*)
;;
*)
hosts+=("$1")
;;
esac
shift
done
pushd "${TMP}"
for host in "${hosts[@]}"; do
if [[ -n "${host}" ]]; then
rsync --ssh "ssh -p ${port} ${opts[*]}" dot.tbz2 "${host}":~
ssh -p "${port}" "${opts[@]}" "${host}" "bash -s -x -- ${remoteOpts}" < "${DOT}/init_remote.bash"
fi
done
popd