-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.sh
173 lines (122 loc) · 4.19 KB
/
script.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
171
172
173
#!/bin/bash
# -*- ENCODING: UTF-8 -*-
function separator {
echo -e "\n\n\n"
}
function check_correct {
if [ $1 ]; then
echo "Instalado !"
else
echo "Hubo un error"
exit 1
fi
}
function add_repositories {
RESULT=false
## add-apt-repository -y ppa:andrei-pozolotin/maven3 && \ # MAVEN
add-apt-repository -y ppa:webupd8team/java && \ # JAVA
apt-get update && RESULT=true
check_correct $RESULT
}
function install_java {
RESULT=false
# Seleccionando la versión de java
JAVA_VERSION=$1
echo "Instalando java$JAVA_VERSION..."
apt-get update && \
echo oracle-java$JAVA_VERSION-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java$JAVA_VERSION-installer libxext-dev libxrender-dev libxtst-dev curl sudo && RESULT=true
check_correct $RESULT
}
function install_maven {
RESULT=false
echo "Instalando maven..."
apt-get install -y maven && RESULT=true
check_correct $RESULT
}
function install_tomcat {
RESULT=false; RESULT2=false
echo "Instalando tomcat$1..."
apt-get install -y tomcat$1 && \
sed -i.bak 's/JAVA_OPTS.*/JAVA_OPTS="-Djava.security.egd=file:\/dev\/\.\/urandom -Djava\.awt\.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:\+UseConcMarkSweepGC"/g' /etc/default/tomcat$1 && \
RESULT=true
check_correct $RESULT
if [ $RESULT ]; then
echo "Habilitandp tomcat$1..."
systemctl restart tomcat$1 && \
systemctl enable tomcat$1 && \
RESULT2=true
check_correct $RESULT2
fi
}
function install_tomcat2 {
RESULT=false
TOMCAT_MAJOR=$1
TOMCAT_VERSION=$2
echo "Instalando tomcat ($TOMCAT_MAJOR/v$TOMCAT_VERSION)..."
apt-get install -y curl && \
bash -c "curl -SL http://apache.uvigo.es/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz | \
tar -C /opt/ -xz" && RESULT=true
check_correct $RESULT
}
function install_eclipse {
RESULT=false
echo "Instalando eclipse ($1)..."
bash -c "curl -SL http://eclipse.c3sl.ufpr.br/technology/epp/downloads/release/$1-linux-gtk-x86_64.tar.gz | \
tar -C /opt/ -xz" && \
ln -s /opt/eclipse/eclipse /usr/bin/eclipse && \
bash -c "curl -SL https://raw.githubusercontent.com/EGCG2/ConfigurationVMS/master/Eclipse/Eclipse.desktop -o /usr/share/applications/Eclipse.desktop" && \
chmod +x /usr/bin/eclipse && RESULT=true
check_correct $RESULT
}
function install_mysql {
RESULT=false
RESULT2=false
RESULT3=false
echo "Instalando MYSQL"
{ \
echo mysql-server-$1 mysql-server/root_password password root; \
echo mysql-server-$1 mysql-server/root_password_again password root; \
echo mysql-server-$1 mysql-server/remove-test-db select false; \
} | /usr/bin/debconf-set-selections
apt-get install -y mysql-server-$1 && RESULT=true
check_correct $RESULT
systemctl restart mysql && \
systemctl enable mysql && RESULT2=true
check_correct $RESULT2
apt-get install -y gmysqlcc && RESULT3=true
check_correct $RESULT3
}
function main {
echo "Actualizando el sistema"
apt-get update && apt-get upgrade -y && apt-get install -y apt-utils software-properties-common curl
echo "Añadiendo usuario al grupo vboxsf para permitir compartir carpetas"
usermod -a -G vboxsf usuario
add_repositories
separator
install_java 7
separator
install_maven
separator
install_tomcat2 7 7.0.72
separator
install_mysql 5.7
separator
install_java 8
separator
install_eclipse neon/1a/eclipse-jee-neon-1a
separator
echo "Finalizado ! !"
}
# Comprobar que el script está corriendo como root
if [[ $EUID -ne 0 ]]; then
echo "Este script debe ser lanzado como root" 1>&2
exit 1
fi
E=`fuser /var/lib/dpkg/lock`
if [[ $E -ne 0 ]]; then
echo -e "Actualmente no es posible instalar los programas porque hay otras actualizaciones en proceso. \nIntentelo más tarde" 1>&2
exit 1
fi
main
exit 0