-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-vm-server.sh
68 lines (51 loc) · 1.9 KB
/
start-vm-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
#! /bin/bash
set -e
set -v
# Talk to the metadata server to get the project id
PROJECTID=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-Flavor: Google")
echo "Project ID: ${PROJECTID}"
# Install dependencies from apt
apt-get install -yq openjdk-17 git maven
mvn --version
# Jetty Setup
mkdir -p /opt/jetty/temp
mkdir -p /var/log/jetty
# Get Jetty
curl -L https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.13.v20181111/jetty-distribution-9.4.13.v20181111.tar.gz -o jetty9.tgz
tar xf jetty9.tgz --strip-components=1 -C /opt/jetty
# Add a Jetty User
useradd --user-group --shell /bin/false --home-dir /opt/jetty/temp jetty
cd /opt/jetty
# Add running as "jetty"
java -jar /opt/jetty/start.jar --add-to-startd=setuid
cd /
# Clone the source repository.
git clone https://github.com/owensulei3841/otlp.git
cd otlp
# Build the .war file and rename.
# very important - by renaming the war to root.war, it will run as the root servlet.
mvn clean package -q
mv target/observability-poc-1.0.war /opt/jetty/webapps/root.war
# Make sure "jetty" owns everything.
chown --recursive jetty /opt/jetty
# Configure the default paths for the Jetty service
cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
echo "JETTY_HOME=/opt/jetty" > /etc/default/jetty
{
echo "JETTY_BASE=/opt/jetty"
echo "TMPDIR=/opt/jetty/temp"
echo "JAVA_OPTIONS=-Djetty.http.port=80"
echo "JETTY_LOGS=/var/log/jetty"
} >> /etc/default/jetty
# Reload daemon to pick up new service
systemctl daemon-reload
# Install logging monitor. The monitor will automatically pickup logs sent to syslog.
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
sudo bash add-logging-agent-repo.sh --also-install
service google-fluentd restart &
service jetty start
service jetty check
#cd ~/otlp
#mvn -Plocal clean jetty:run-exploded -DprojectID=opentelemetryvm
echo "Startup Complete"
# [END script]