-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_server.sh
executable file
·135 lines (99 loc) · 3 KB
/
config_server.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
function fix_disk {
echo "Arranging data disk"
echo "Un mounting data disk"
umount /dev/sdb1
echo "Wiping diskk"
dd if=/dev/zero of=/dev/sdb bs=1024 count=8096
echo "Creating partition table"
parted -s /dev/sdb mktable gpt
echo "Creating partition"
parted -s /dev/sdb mkpart primary ext4 0% 100%
echo "Reading partition tables"
partprobe
echo "Formatting disk with ext4"
mkfs.ext4 /dev/sdb1
echo "Mounting disk"
mount /dev/sdb1
}
function create_links {
echo "Creating folders and symlinks for ${real_user} and ${HOME}"
rm -rf ${HOME}/go /var/lib/docker ${HOME}/projects
mkdir /mnt/docker
mkdir /mnt/go
mkdir /mnt/projects
chown ${real_user}:${real_user} /mnt/go /mnt/projects
ln -s /mnt/go ${HOME}/go
ln -s /mnt/docker /var/lib/docker
ln -s /mnt/projects ${HOME}/projects
chown -h ${real_user}:${real_user} ${HOME}/go ${HOME}/projects
}
function install_go {
apt-get -y install unzip
filename='go1.13.4.linux-amd64.tar.gz'
wget "https://dl.google.com/go/${filename}"
tar -C /usr/local -xzf ${filename}
echo 'export GOPATH=$HOME/go' >> ~/.bash_profile
echo 'export GOROOT=/usr/local/go' >> ~/.bash_profile
echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> ~/.bash_profile
}
function install_terraform {
filename='terraform_0.12.16_linux_amd64.zip'
wget "https://releases.hashicorp.com/terraform/0.12.16/${filename}"
unzip ${filename}
mv terraform /usr/local/bin
}
function install_az_cli {
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
}
function install_docker_repo {
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
}
function install_docker {
apt-get -y install docker-ce docker-ce-cli containerd.io
usermod -aG docker ${real_user}
}
function install_systools {
apt-get -y install iftop iotop sysstat
}
function install_chrome {
apt-get -y install fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatspi2.0-0 libgtk-3-0 libnspr4 libnss3 libx11-xcb1 xdg-utils libxss1
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome*.deb
}
function install_dev_tools {
apt-get -y install make gcc
}
function install_all {
apt-get update -y
install_docker_repo
apt-get update -y
install_systools
install_docker
install_go
install_terraform
install_az_cli
install_chrome
install_dev_tools
}
set -e
if [ "$1" != "" ]; then
real_user="$1"
HOME="/home/${real_user}"
else
echo "The script must be invoked with the username as first argument"
exit 1
fi
fix_disk
create_links
install_all