Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docker-compose-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -e

echo "Updating system packages..."
sudo dnf update -y

echo "Installing Docker..."
sudo dnf install -y docker

echo "Starting and enabling Docker service..."
sudo systemctl enable docker
sudo systemctl start docker

echo "Adding ec2-user to docker group..."
sudo usermod -aG docker ec2-user

echo "Detecting architecture..."
ARCH=$(uname -m)

if [ "$ARCH" = "x86_64" ]; then
COMPOSE_BINARY="docker-compose-linux-x86_64"
elif [ "$ARCH" = "aarch64" ]; then
COMPOSE_BINARY="docker-compose-linux-aarch64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi

echo "Installing Docker Compose..."
sudo mkdir -p /usr/local/lib/docker/cli-plugins

sudo curl -SL \
"https://github.com/docker/compose/releases/latest/download/${COMPOSE_BINARY}" \
-o /usr/local/lib/docker/cli-plugins/docker-compose

sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

echo "Restarting Docker..."
sudo systemctl restart docker

echo ""
echo "Docker Version:"
docker --version

echo ""
echo "Docker Compose Version:"
docker compose version

echo ""
echo "Installation completed successfully."
echo "Log out and log back in (or run 'newgrp docker') before using Docker without sudo."
55 changes: 55 additions & 0 deletions jenkins.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@

#!/bin/bash

# STEP-1: UPDATE SYSTEM
yum update -y

# STEP-2: INSTALL GIT
yum install -y git

# STEP-3: ADD JENKINS REPOSITORY
wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo

rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

# STEP-4: INSTALL JAVA 21
yum install -y java-21-amazon-corretto

# STEP-5: INSTALL JENKINS
yum install -y jenkins

# STEP-6: CREATE SWAP (2GB)
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

echo "/swapfile swap swap defaults 0 0" >> /etc/fstab

# STEP-7: CREATE DEDICATED JENKINS TEMP DIRECTORY
mkdir -p /var/tmp/jenkins
chown jenkins:jenkins /var/tmp/jenkins

# STEP-8: SET JAVA MEMORY + TEMP DIRECTORY
sed -i '/Environment="JAVA_OPTS=/d' \
/usr/lib/systemd/system/jenkins.service

sed -i '/^\[Service\]/a Environment="JAVA_OPTS=-Djava.io.tmpdir=/var/tmp/jenkins -Xms256m -Xmx512m"' \
/usr/lib/systemd/system/jenkins.service

# STEP-9: RELOAD SYSTEMD
systemctl daemon-reload

# STEP-10: START JENKINS
systemctl start jenkins
systemctl enable jenkins

# STEP-11: CHECK STATUS
systemctl status jenkins --no-pager

echo ""
echo "Initial Jenkins Password:"
cat /var/lib/jenkins/secrets/initialAdminPassword
=======
yum install java-21-amazon-corretto -y
sudo wget -O /etc/yum.repos.d/jenkins.repo     https://pkg.jenkins.io/rpm-stable/jenkins.repo
yum install jenkins -y
systemctl start jenkins
systemctl status jenkins

2 changes: 1 addition & 1 deletion nexus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo yum update -y
sudo yum install wget -y
sudo yum install java-17-amazon-corretto-jmods -y
sudo yum install java-21-amazon-corretto-jmods -y
sudo mkdir /app && cd /app
sudo wget https://download.sonatype.com/nexus/3/nexus-3.79.1-04-linux-x86_64.tar.gz
sudo tar -xvf nexus-3.79.1-04-linux-x86_64.tar.gz
Expand Down
92 changes: 78 additions & 14 deletions sonar.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,78 @@
#! /bin/bash
#Launch an instance with 9000 and t2.medium
cd /opt/
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.9.6.50800.zip
unzip sonarqube-8.9.6.50800.zip
yum install java-17-amazon-corretto -y
useradd sonar
chown sonar:sonar sonarqube-8.9.6.50800 -R
chmod 777 sonarqube-8.9.6.50800 -R
su - sonar

#run this on server manually
#sh /opt/sonarqube-8.9.6.50800/bin/linux/sonar.sh start
#echo "user=admin & password=admin"
#!/bin/bash

# Update packages
sudo dnf update -y

# Install required packages
sudo dnf install -y wget unzip java-21-amazon-corretto

# Verify Java
java -version

# Create sonar user if not exists
id sonar >/dev/null 2>&1 || sudo useradd sonar

# Go to /opt
cd /opt

# Download SonarQube 10.x
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.6.0.92116.zip

# Extract
sudo unzip sonarqube-10.6.0.92116.zip

# Rename directory
sudo mv sonarqube-10.6.0.92116 sonarqube

# Set ownership
sudo chown -R sonar:sonar /opt/sonarqube

# Set permissions
sudo chmod -R 755 /opt/sonarqube

# Linux kernel settings required by Elasticsearch
echo "vm.max_map_count=524288" | sudo tee -a /etc/sysctl.conf
echo "fs.file-max=131072" | sudo tee -a /etc/sysctl.conf

sudo sysctl -p

# User limits
cat <<EOF | sudo tee -a /etc/security/limits.conf
sonar - nofile 131072
sonar - nproc 8192
EOF

# Create SonarQube systemd service
sudo tee /etc/systemd/system/sonarqube.service > /dev/null <<EOF
[Unit]
Description=SonarQube Service
After=network.target

[Service]
Type=forking

User=sonar
Group=sonar

ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

Restart=always
LimitNOFILE=131072
LimitNPROC=8192

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd
sudo systemctl daemon-reload

# Enable SonarQube
sudo systemctl enable sonarqube

# Start SonarQube
sudo systemctl start sonarqube

# Check status
sudo systemctl status sonarqube --no-pager