-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbd6ea2
commit 52e8209
Showing
6 changed files
with
71 additions
and
51 deletions.
There are no files selected for viewing
14 changes: 9 additions & 5 deletions
14
todo-app/aws/3-tier-app/lab/services/todo/app/templates/deployment.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
#!/bin/bash -x | ||
|
||
export MYSQL_HOST='${MYSQL_HOST}' | ||
export MYSQL_DB_NAME='${MYSQL_DB_NAME}' | ||
export MYSQL_USER='${MYSQL_USER}' | ||
export MYSQL_PASSWORD='${MYSQL_PASSWORD}' | ||
# Export mysql environment variables | ||
systemctl set-environment MYSQL_HOST=${MYSQL_HOST} | ||
systemctl set-environment MYSQL_DB_NAME=${MYSQL_DB_NAME} | ||
systemctl set-environment MYSQL_USER=${MYSQL_USER} | ||
systemctl set-environment MYSQL_PASSWORD=${MYSQL_PASSWORD} | ||
|
||
|
||
# bootstrap todo app | ||
java -server -Dfile.encoding=utf-8 -XX:+ExitOnOutOfMemoryError -Djava.security.egd=file:/dev/./urandom -Duser.timezone=UTC -jar /opt/app.jar | ||
sudo systemctl daemon-reload | ||
sudo systemctl enable todo.service | ||
sudo systemctl start todo |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
# Install necessary dependencies | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common | ||
sudo DEBIAN_FRONTEND=noninteractive apt-add-repository universe | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade | ||
sudo apt-get -y -qq install curl git openjdk-11-jdk maven apt-transport-https ca-certificates | ||
|
||
# Setup sudo to allow no-password sudo for "psi" group and adding "todo" user | ||
sudo groupadd -r psi | ||
sudo useradd -m -s /bin/bash todo | ||
sudo usermod -a -G psi todo | ||
sudo cp /etc/sudoers /etc/sudoers.orig | ||
echo "todo ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/todo | ||
|
||
# Installing SSH key | ||
sudo mkdir -p /home/todo/.ssh | ||
sudo chmod 700 /home/todo/.ssh | ||
sudo cp /tmp/todo.pub /home/todo/.ssh/authorized_keys | ||
sudo chmod 600 /home/todo/.ssh/authorized_keys | ||
sudo chown -R todo /home/todo/.ssh | ||
sudo usermod --shell /bin/bash todo | ||
|
||
|
||
|
||
# Create JAVA_HOME for todo & download the todo-app from github | ||
|
||
sudo -H -i -u todo -- env bash << EOF | ||
whoami | ||
echo ~todo | ||
cd /home/todo | ||
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/ | ||
export PATH=$PATH:$JAVA_HOME/bin | ||
git clone https://github.com/Raghav2211/psi-lab.git | ||
cd psi-lab/todo-app | ||
mvn clean package -DskipTests | ||
sudo mkdir /opt/todo | ||
sudo cp target/psi-todo-${APP_VERSION}.jar /opt/todo/app.jar | ||
sudo cp /tmp/bootstrap.sh /opt/todo/bootstrap.sh | ||
sudo chmod 744 /opt/todo/bootstrap.sh | ||
sudo cp /tmp/app.service /etc/systemd/system/todo.service | ||
cd ../.. | ||
rm -r psi-lab | ||
EOF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Todo Application as a Service | ||
[Service] | ||
User=todo | ||
#path to the executable bash script which executes todo app | ||
ExecStart=/bin/bash /opt/todo/bootstrap.sh | ||
SuccessExitStatus=143 | ||
TimeoutStopSec=10 | ||
Restart=on-failure | ||
RestartSec=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
java -server -Dfile.encoding=utf-8 -XX:+ExitOnOutOfMemoryError -Djava.security.egd=file:/dev/./urandom -Duser.timezone=UTC -jar /opt/todo/app.jar |