-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-linux.sh
executable file
·93 lines (78 loc) · 2.17 KB
/
setup-linux.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
sudo true
if [[ "$MACHINE" != "Linux" ]]; then
echo "$MACHINE is not supported"
exit 1
fi
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$NAME
else
echo "Cannot determine Distro"
fi
if [[ "$DISTRO" != *"Rasp"* ]] && [[ "$DISTRO" != *"Debian"* ]] && [[ "$DISTRO" != *"Ubuntu"* ]]; then
echo "$DISTRO is not supported"
exit 1
fi
if [[ $EUID -gt 0 ]]; then
echo "Please run with sudo"
exit
fi
install_zsh_etc() {
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
sudo apt update
sudo apt -y install \
apt-transport-https \
ca-certificates \
curl \
fzf \
gnupg-agent \
npm \
silversearcher-ag \
software-properties-common \
subversion \
zsh
zsh --version
chsh -s /bin/zsh
}
install_docker() {
if [[ "$(arch)" == "x86_64" ]]; then
ARCH="amd64"
elif [[ "$(arch)" == "aarch64" ]]; then
ARCH="arm64"
fi
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=$ARCH] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt -y install \
docker-ce \
docker-ce-cli \
containerd.io
COMPOSE_VERSION=$(git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oE "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1)
curl -L --fail "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/run.sh" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
}
create_symlinks() {
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
for file in "$DIR"/dotfiles/.*; do
if [ -d "$file" ] || [[ "$file" == *"gitconfig"* ]]; then
continue
fi
file_name="${file##*/}"
ln -sfn "$file" /home/gordonpn/"$file_name"
done
}
read -r -p "Install zsh? [y/N] " response
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]; then
install_zsh_etc
fi
read -r -p "Install Docker? [y/N] " response
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]; then
install_docker
fi
echo "Creating symlinks"
create_symlinks
echo "Done creating symlinks"
echo "Please set your shell to zsh manually: chsh -s /bin/zsh"