forked from microsoft/PartsUnlimitedMRP
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInstall-MRP-app.sh
91 lines (67 loc) · 2.64 KB
/
Install-MRP-app.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
while [[ ${1} ]]
do
case "${1}" in
-a|--storage-account)
DropStorageAccountName="$2"
shift # past argument
;;
-c|--container)
DropContainerName="$2"
shift # past argument
;;
*)
#unknown option
;;
esac
shift #past argument or value
done
# Kill java to stop current website
pkill -9 'java'
# Remove old artifacts
rm -f /var/lib/partsunlimited/MongoRecords.js*
rm -f /var/lib/partsunlimited/mrp.war*
rm -f /var/lib/partsunlimited/ordering-service-0.1.0.jar*
# Install packages
sudo apt-get update
sudo apt-get install openjdk-8-jdk -y
sudo apt-get install openjdk-8-jre -y
sudo apt-get install mongodb -y
sudo apt-get install tomcat7 -y
sudo apt-get install tomcat7-admin -y
sudo apt-get install wget -y
# Set Java environment variables
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk-amd64/bin
# Configure the storage account and container name here
AzureResource="https://$DropStorageAccountName.blob.core.windows.net/$DropContainerName/"
# Download MongoRecords.js from Azure blog storage
#wget ${AzureResource}MongoRecords.js -P /var/lib/partsunlimited
#copy MongoOrdering.js
sudo mv ./MongoRecords.js /var/lib/partsunlimted/MongoRecords.js
# Wait for 10 seconds to make sure previous step is completed
sleep 10
# Add the records to ordering database on MongoDB
mongo ordering /var/lib/partsunlimited/MongoRecords.js
# Change Tomcat listening port from 8080 to 9080
sudo sed -i s/8080/9080/g /etc/tomcat7/server.xml
sudo mv /etc/tomcat7/tomcat-users.xml /etc/tomcat7/tomcat-users.xml.bak
sudo cat /etc/tomcat7/tomcat-users.xml.bak | awk '{ x[NR] = $0 } END { for ( i=1 ; i<=NR ; i++ ) { if (x[i] ~ /<user username="tomcat"/ ) {x[i]="--><user username=\"tomcat\" password=\"P2ssw0rd\" roles=\"tomcat,manager-gui,manager-script,admin-gui\"/><!--"}print x[i] }} ' > tomcat-users.xml
sudo mv ./tomcat-users.xml /etc/tomcat7/
# Download the client WAR file
#wget ${AzureResource}mrp.war -P /var/lib/partsunlimited/
# Wait for 10 seconds to make sure previous step is completed
#sleep 10
# Copy WAR file to Tomcat directory for auto-deployment
sudo /etc/init.d/tomcat7 stop
sleep 5
#rm -rf /var/lib/tomcat7/webapps/mrp*
#cp /var/lib/partsunlimited/mrp.war /var/lib/tomcat7/webapps
# Restart Tomcat
sudo /etc/init.d/tomcat7 restart
# Download the Ordering Service jar from Azure storage
sudo wget ${AzureResource}ordering-service-0.1.0.jar -P /var/lib/partsunlimited/
# Wait for 20 seconds to make sure previous step is completed
sleep 20
# Run Ordering Service app
java -jar /var/lib/partsunlimited/ordering-service-0.1.0.jar &
echo "MRP application successfully deployed. Go to http://$HOSTNAME.cloudapp.net:9080/mrp"