-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·76 lines (65 loc) · 1.89 KB
/
install.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
#!/bin/bash
# Check the current user is root or not.
if [ $EUID -ne 0 ]; then
echo "You're not root user. using sudo to continue."
case $0 in
bash)
sudo $0 -s $*
;;
*)
sudo bash $0 $*
;;
esac
exit 0
fi
checkpackages() {
for prg in $*; do
hash $prg 2>/dev/null || return 1
done
return 0
}
versiongte() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]
}
install_maven() {
version=$1
echo "Download and install maven ${version} ..."
curl -sSL http://archive.apache.org/dist/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz |\
tar -C /opt/ -xzf -
ln -sf /opt/apache-maven-${version}/bin/mvn /usr/bin/mvn
}
if ! checkpackages curl git javac; then
# Update repository
echo "Update repository ..."
apt-get update -qq
# Install dependencies
echo "Installing JDK and other dependencies ..."
apt-get install -qq curl git openjdk-7-jre openjdk-7-jdk
else
echo "Dependencies are already installed"
fi
# Maven 3.0.1 or higher required.
mvn_version_to_install='3.3.9'
mvn_version=$(mvn -v 2>/dev/null | grep 'Apache Maven' | awk '{print $3}')
if hash mvn && versiongte $mvn_version '3.0.1'; then
echo "Required maven version is already installed."
else
install_maven $mvn_version_to_install
fi
# Copy maven settings
echo "Copying maven settings ..."
if [ -x ~/.m2/settings.xml ]; then
mv ~/.m2/settings.xml{,.bak}
fi
mkdir -p ~/.m2
chown -R $SUDO_USER:$SUDOUSER ~/.m2
curl -sSL -o ~/.m2/settings.xml \
https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
# Setting maven opts
if ! grep MAVEN_OPTS ~/.bashrc >/dev/null; then
echo "Setting maven options to profile ..."
echo "export MAVEN_OPTS='-Xmx1048m -XX:MaxPermSize=1024m'" >> ~/.bashrc
else
echo "Maven option is already given."
fi
echo "Done!"