-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-ubuntu-16.04-amd64.sh
executable file
·171 lines (133 loc) · 4.58 KB
/
setup-ubuntu-16.04-amd64.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
REFRESH_RATE=60
RESOLUTIONS="1920x1080"
FORCE=
chmod +x ./*.sh
if [ -d target ]; then
rm -rf target
fi
mkdir target
# Create .bash_profile if it does not exist, and source .bashrc in it
if [ ! -f ~/.bash_profile ] || [ -z "$(cat ~/.bash_profile | grep bashrc | cat)" ]; then
echo >> ~/.bash_profile
echo "source ~/.bashrc" >> ~/.bash_profile
fi
# Appends a line to the end of the ~/.bashrc file to export a key and its value
# if the key is already present it won't be appended again
function export_to_bashrc {
local key=$1
local value=$2
if [ "$value" ]; then
local result=`cat ~/.bashrc | grep "$key=" | cat`
if [ -z "$result" ]; then
echo >> ~/.bashrc
echo "export $key=$value" >> ~/.bashrc
fi
else
local result=`cat ~/.bashrc | grep "$key" | cat`
if [ -z "$result" ]; then
echo >> ~/.bashrc
echo "$key" >> ~/.bashrc
fi
fi
}
function add_to_path {
local key=$1
local result=`cat ~/.bashrc | grep "PATH" | grep $key | cat`
if [ -z "$result" ]; then
echo >> ~/.bashrc
echo "export PATH=\$PATH:\$$key" >> ~/.bashrc
fi
}
./apt-update.sh
sudo apt-get upgrade -y
sudo apt-get install -y apt apt-transport-https ca-certificates
# Docker
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# Sources
echo; echo "Copying bash aliases"; echo
sudo cp -f my-sources.list /etc/apt/sources.list.d/
sudo apt update
# Install tools
sudo apt install -y git vim tree htop traceroute terminator shellcheck gpg2 devscripts
sudo apt install -y chromium-browser gitkraken shutter konsole krusader ffmpeg gtk-recordmydesktop imagemagick mplayer
sudo apt install -y postgresql postgresql-contrib postgresql-client pgadmin3
sudo apt install -y python-pip build-essential libssl-dev python2.7-dev libxml2-dev libxslt1-dev
# Docker
sudo apt-get purge lxc-docker
apt-cache policy docker-engine
sudo apt install -y docker-engine
# Install Java
sudo apt-get install -y openjdk-8-jdk
export_to_bashrc "JAVA_HOME" "/usr/lib/jvm/java-8-openjdk-amd64"
add_to_path "JAVA_HOME/bin"
# Install Maven
sudo apt install -y maven
export_to_bashrc "MAVEN_OPTS" "\"-Xmx2g -XX:MaxPermSize=256m\""
export_to_bashrc "M2_HOME" "/usr/share/maven"
add_to_path "M2_HOME/bin"
# PostgreSQL
#echo "\password postgres" | sudo -u postgres psql postgres
#sudo -u postgres createdb sonarqube
# Install NodeJS
if [ -z $(node --version | grep "^v[0-9]*" | cat) ] || [ "$FORCE" ]; then
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt install -y nodejs
sudo apt-get install -y build-essential
else
echo "Node already installed: $(node --version)"
fi
# Install Microsoft Code
if [ -z $(code --version | grep "^[0-9]*" | cat) ] || [ "$FORCE" ]; then
cd target
MS_CODE_DIR=ms-code
MS_CODE_URL=https://go.microsoft.com/fwlink/?LinkID=760868
mkdir $MS_CODE_DIR
cd $MS_CODE_DIR
wget -O code.deb $MS_CODE_URL
sudo dpkg -i code.deb
sudo apt-get install -f -y
cd ..
rm -rf $MS_CODE_DIR
cd ..
else
echo "MS Code already installed: $(code --version)"
fi
# Add resolutions if they do not exist, mostly for VMs
for resolution in $RESOLUTIONS
do
echo "Attemtping to add resolution: $resolution"
if [ -z "$(xrandr -q | grep $resolution | cat)" ]; then
WIDTH=`echo $resolution | cut -d'x' -f1`
HEIGHT=`echo $resolution | cut -d'x' -f2`
NEW_MODE=`sudo cvt $WIDTH $HEIGHT $REFRESH_RATE | grep Modeline | sed -e "s/^Modeline //"`
sudo xrandr --newmode $NEW_MODE
DEVICE_NAME=`sudo xrandr -q | grep "connected primary" | cut -d' ' -f1`
sudo xrandr --addmode $DEVICE_NAME $WIDTHx$HEIGHT_$REFRESH_RATE.00
else
echo "Resolution $resolution already present, will not add."
fi
done
# Fingerprint
#sudo add-apt-repository ppa:fingerprint/fprint
#sudo apt-get update
#sudo apt-get upgrade -y
#sudo echo | apt-get install -y libfprint0 fprint-demo libpam-fprintd
# Set up DNS
RESOLV_CONF_FILE=/etc/resolvconf/resolv.conf.d/base
if [ ! -f $RESOLV_CONF_FILE ] || [ -z "$(cat $RESOLV_CONF_FILE | grep "8.8.8.8" | cat)" ]; then
echo "nameserver 8.8.8.8" | sudo tee $RESOLV_CONF_FILE > /dev/null
fi
# Aliases
echo; echo "Copying bash aliases"; echo
cp -f bash_aliases ~/.bash_aliases
# My custom bashrc
echo; echo "Copying my_bashrc"; echo
cp -f my_bashrc.sh ~/.my_bashrc
export_to_bashrc "source ~/.my_bashrc"
# Remove stuff
echo; echo "Removing stuff"; echo
sudo apt-get remove -y --purge libreoffice* > /dev/null
sudo apt-get clean
sudo apt-get autoremove -y
rm -rf target