-
Notifications
You must be signed in to change notification settings - Fork 1
/
minimal-setup.sh
executable file
·58 lines (49 loc) · 1.31 KB
/
minimal-setup.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
55
56
57
58
#!/bin/sh
set -eu
stderr() {
echo >&2 "$@"
}
check_user() {
if test "$USER" != "cceckman"
then
stderr "\$USER is not cceckman; refusing to perform local setup."
stderr "(Assuming this is a shared machine.)"
exit 1
fi
stderr "\$USER is cceckman, proceeding."
}
check_sudo() {
stderr "Checking / obtaining sudo permissions..."
if ! sudo echo >&2 "Successfully authenticated!"
then
stderr "Could not perform sudo authentication."
stderr "Do you have permission to install onto this host?"
exit 1
fi
stderr "Can use sudo."
}
init_ssh() {
stderr "Seeding authorized_keys..."
if ! test -f ~/.ssh/authorized_keys
then
stderr "No authorized_keys present; seeding with init key"
(umask 0077; mkdir -p ~/.ssh; cp "$1" ~/.ssh/authorized_keys)
fi
}
main() {
check_user
check_sudo
set +x
# Include terminfo so we can SSH here
sudo -n apt-get install -y tmux zsh vim ripgrep moreutils foot-terminfo mtr-tiny
ZSH="$(cat /etc/shells | grep zsh | head -1)"
sudo -n usermod --shell "$ZSH" "$USER"
set -x
TILDE="$(dirname "$(readlink -f "$0")")"
init_ssh "$TILDE"/id_init.pub
ln -sf "$TILDE"/tmux.conf "$HOME"/.tmux.conf
ln -sf "$TILDE"/rcfiles/inputrc "$HOME"/.inputrc
ln -sf "$TILDE"/rcfiles "$HOME"
ln -sf "$HOME"/rcfiles/portablerc.sh "$HOME"/.zshrc
}
main "$@"