-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-chip
executable file
·53 lines (46 loc) · 995 Bytes
/
init-chip
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
#!/usr/bin/env bash
parse_args () {
if [ $# -lt 1 ]; then
echo "usage: please enter a host name to target."
exit
fi
host=$1
user='chip'
pass='chip'
}
main () {
echo "registering this machine with chip host ..."
register_push $user $host $pass && \
echo "registration complete."
echo "setting up locales ..."
setup_locales && \
echo "locales complete."
}
# copy our ssh pub key to remote
register_push () {
expect <<-CMDS
spawn ssh-copy-id "$user@$host"
expect "password:"
send "$pass\n"
expect eof
CMDS
}
# setup locales on remote
setup_locales () {
expect <<-CMDS
spawn ssh -t "$user@$host" \
"sudo apt-get update && \
sudo apt-get install -y locales && \
locale-gen en_US en_US.UTF-8 && \
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8"
expect "password for $user:"
send "$pass\n"
expect "password for $user:"
send "$pass\n"
expect "password for $user:"
send "$pass\n"
expect eof
CMDS
}
parse_args $@
main