Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized installation Script #1007

Open
wants to merge 1 commit into
base: release/2.1.0
Choose a base branch
from
Open
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
182 changes: 71 additions & 111 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,127 +1,87 @@
#!/bin/bash

tput setaf 2;
cat web/art/reNgine.txt

tput setaf 1; echo "Before running this script, please make sure Docker is running and you have made changes to .env file."
tput setaf 2; echo "Changing the postgres username & password from .env is highly recommended."

tput setaf 4;
read -p "Are you sure, you made changes to .env file (y/n)? " answer
case ${answer:0:1} in
y|Y|yes|YES|Yes )
echo "Continiuing Installation!"
;;
* )
nano .env
;;
esac

echo " "
tput setaf 3;
echo "#########################################################################"
echo "Please note that, this installation script is only intended for Linux"
echo "For Mac and Windows, refer to the official guide https://rengine.wiki"
echo "#########################################################################"

echo " "
tput setaf 4;
echo "Installing reNgine and it's dependencies"

echo " "
if [ "$EUID" -ne 0 ]
then
tput setaf 1; echo "Error installing reNgine, Please run this script as root!"
tput setaf 1; echo "Example: sudo ./install.sh"
exit

#log messages in different colors
log() {
tput setaf "$2"
echo "$1"
tput sgr0 # Reset text color
}

# Check for root privileges
if [ "$(id -u)" -ne 0 ]; then
log "Error: Please run this script as root!" 1
log "Example: sudo $0" 1
exit 1
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing curl..."
echo "#########################################################################"
if [ -x "$(command -v curl)" ]; then
tput setaf 2; echo "CURL already installed, skipping."

log "#########################################################################" 4
log "Please note that this installation script is only intended for Linux" 3
log "For Mac and Windows, refer to the official guide https://rengine.wiki" 3
log "#########################################################################" 4

log "Installing reNgine and its dependencies" 4

log "#########################################################################" 4
log "Installing curl..." 4

if ! command -v curl &> /dev/null; then
apt update && apt install curl -y
log "CURL installed!!!" 2
else
sudo apt update && sudo apt install curl -y
tput setaf 2; echo "CURL installed!!!"
log "CURL already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing Docker..."
echo "#########################################################################"
if [ -x "$(command -v docker)" ]; then
tput setaf 2; echo "Docker already installed, skipping."
else

log "#########################################################################" 4
log "Installing Docker..." 4

if ! command -v docker &> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
tput setaf 2; echo "Docker installed!!!"
fi


echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing docker-compose"
echo "#########################################################################"
if [ -x "$(command -v docker-compose)" ]; then
tput setaf 2; echo "docker-compose already installed, skipping."
log "Docker installed!!!" 2
else
log "Docker already installed, skipping." 2
fi

log "#########################################################################" 4
log "Installing docker-compose" 4

if ! command -v docker-compose &> /dev/null; then
curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
tput setaf 2; echo "docker-compose installed!!!"
log "docker-compose installed!!!" 2
else
log "docker-compose already installed, skipping." 2
fi


echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing make"
echo "#########################################################################"
if [ -x "$(command -v make)" ]; then
tput setaf 2; echo "make already installed, skipping."

log "#########################################################################" 4
log "Installing make" 4

if ! command -v make &> /dev/null; then
apt install make -y
log "make installed!!!" 2
else
apt install make
log "make already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Checking Docker status"
echo "#########################################################################"

log "#########################################################################" 4
log "Checking Docker status" 4

if docker info >/dev/null 2>&1; then
tput setaf 4;
echo "Docker is running."
log "Docker is running." 4
else
tput setaf 1;
echo "Docker is not running. Please run docker and try again."
echo "You can run docker service using sudo systemctl start docker"
log "Docker is not running. Please run docker and try again." 1
log "You can run Docker service using: sudo systemctl start docker" 1
exit 1
fi



echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing reNgine"
echo "#########################################################################"
make certs && make build && make up && tput setaf 2 && echo "reNgine is installed!!!" && failed=0 || failed=1

if [ "${failed}" -eq 0 ]; then
sleep 3

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Creating an account"
echo "#########################################################################"
make username

tput setaf 2 && printf "\n%s\n" "Thank you for installing reNgine, happy recon!!"
else
tput setaf 1 && printf "\n%s\n" "reNgine installation failed!!"
fi

log "#########################################################################" 4
log "Installing reNgine" 4

make certs && make build && make up && log "reNgine is installed!!!" 2 || { log "reNgine installation failed!!" 1; exit 1; }

log "#########################################################################" 4
log "Creating an account" 4

make username

log "Thank you for installing reNgine, happy recon!!" 2