mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-17 08:54:19 +00:00
Update before_install.sh
This commit is contained in:
parent
d2dd1069bd
commit
d0d0eb7b53
1 changed files with 31 additions and 31 deletions
|
|
@ -1,43 +1,43 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status
|
touch /home/ubuntu/status.txt
|
||||||
set -x # Print commands and their arguments as they are executed
|
|
||||||
|
|
||||||
# Log function to capture error messages
|
sudo apt-get -y update
|
||||||
log() {
|
# sudo rm -rf /home/ubuntu/install
|
||||||
echo "$1" >> /var/log/codedeploy_before_install.log
|
echo "A" >> /home/ubuntu/status.txt
|
||||||
}
|
|
||||||
|
|
||||||
log "Updating apt-get"
|
|
||||||
sudo apt-get -y update || { log "apt-get update failed"; exit 1; }
|
|
||||||
|
|
||||||
log "Checking for /home/ubuntu/install"
|
|
||||||
if [ ! -f "/home/ubuntu/install" ]; then
|
if [ ! -f "/home/ubuntu/install" ]; then
|
||||||
log "Installing CodeDeploy agent"
|
# install CodeDeploy agent
|
||||||
sudo apt-get -y install ruby || { log "ruby installation failed"; exit 1; }
|
echo "B" >> /home/ubuntu/status.txt
|
||||||
sudo apt-get -y install wget || { log "wget installation failed"; exit 1; }
|
sudo apt-get -y install ruby
|
||||||
|
sudo apt-get -y install wget
|
||||||
cd /home/ubuntu
|
cd /home/ubuntu
|
||||||
wget https://aws-codedeploy-eu-north-1.s3.amazonaws.com/latest/install || { log "wget failed"; exit 1; }
|
wget https://aws-codedeploy-eu-north-1.s3.amazonaws.com/latest/install
|
||||||
sudo chmod +x ./install
|
sudo chmod +x ./install
|
||||||
sudo ./install auto || { log "CodeDeploy agent installation failed"; exit 1; }
|
sudo ./install auto
|
||||||
|
echo "C" >> /home/ubuntu/status.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Installing golang-go"
|
# install golang
|
||||||
sudo apt-get -y install golang-go || { log "golang-go installation failed"; exit 1; }
|
sudo apt-get -y install golang-go
|
||||||
|
echo "D" >> /home/ubuntu/status.txt
|
||||||
|
|
||||||
log "Installing nodejs and npm"
|
# install nodeJS and npm
|
||||||
sudo apt -y install nodejs || { log "nodejs installation failed"; exit 1; }
|
sudo apt -y install nodejs
|
||||||
sudo apt -y install npm || { log "npm installation failed"; exit 1; }
|
echo "E" >> /home/ubuntu/status.txt
|
||||||
|
sudo apt -y install npm
|
||||||
|
echo "F" >> /home/ubuntu/status.txt
|
||||||
|
|
||||||
log "Checking for MongoDB installation"
|
# Install MongoDB only if not already present
|
||||||
if [ ! -f "/usr/bin/mongod" ]; then
|
if [ ! -f "/usr/bin/mongod" ]; then
|
||||||
log "Installing MongoDB"
|
echo "G" >> /home/ubuntu/status.txt
|
||||||
sudo apt-get install -y gnupg curl || { log "gnupg or curl installation failed"; exit 1; }
|
sudo apt-get install gnupg curl
|
||||||
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor || { log "MongoDB GPG key download failed"; exit 1; }
|
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
|
||||||
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list || { log "MongoDB repository addition failed"; exit 1; }
|
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
|
||||||
sudo apt-get update || { log "apt-get update failed after adding MongoDB repository"; exit 1; }
|
--dearmor
|
||||||
sudo apt-get install -y mongodb-org || { log "mongodb-org installation failed"; exit 1; }
|
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
|
||||||
sudo apt-get install -y mongosh || { log "mongosh installation failed"; exit 1; }
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y mongodb-org
|
||||||
|
sudo apt-get install -y mongosh
|
||||||
|
echo "H" >> /home/ubuntu/status.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "BeforeInstall script completed successfully"
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue