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

build(install/uninstall/update): improve usability, readability and overall user experience of output #95

Merged
merged 26 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ad3ad4c
build(installation): make users aware of installation time
AnonymousWP Jun 7, 2024
b5846f0
build(installation): remove redundant exclamation marks and use new r…
AnonymousWP Jun 7, 2024
4a410d7
build(docker): use Docker Compose V2 commands
AnonymousWP Jun 7, 2024
927774a
build(docker): fix leftover Docker Compose V1 commands
AnonymousWP Jun 7, 2024
d9ea8ac
build(docker): update Docker Compose to 2.27.1
AnonymousWP Jun 7, 2024
1dc77d8
build(install): change colours for better readability
AnonymousWP Jun 8, 2024
2fd59aa
build(uninstall): replace echo by log
AnonymousWP Jun 8, 2024
61390c2
build(uninstall): use variables for setting colour
AnonymousWP Jun 8, 2024
45fc896
build(install): use variables for setting colour
AnonymousWP Jun 8, 2024
51b18a5
build(install): remove hashtags and equal signs
AnonymousWP Jun 8, 2024
eb9fc89
build(uninstall): fix typo
AnonymousWP Jun 8, 2024
f3ab232
build(install): fix wrong error message
AnonymousWP Jun 8, 2024
b641c18
build(install): replace numbers by variable
AnonymousWP Jun 8, 2024
4558ae2
build(uninstall): don't show uninstalling string when not sudo
AnonymousWP Jun 10, 2024
97700ec
build(docker-compose): always use latest release
AnonymousWP Jun 10, 2024
b4dd35d
build(update): add colours for output
AnonymousWP Jun 10, 2024
67c6077
build(install/uninstall): fix typos
AnonymousWP Jun 10, 2024
57babf5
build(install): install dependencies dynamically based on used reposi…
AnonymousWP Jun 10, 2024
b7ba19f
Merge branch 'master' into replace-names/urls-to-fork
AnonymousWP Jun 10, 2024
4fd579c
build(docker): remove commented and empty line
AnonymousWP Jun 18, 2024
eb5f45f
build(install): print URL of reNgine-ng after successful installation
AnonymousWP Jun 18, 2024
65eadcf
fix(update-check): use reNgine-ng repo
AnonymousWP Jun 27, 2024
ef162c6
fix(banner): use reNgine-ng repo for issues
AnonymousWP Jun 27, 2024
c81f78c
build(version): bump to 2.0.6
AnonymousWP Jun 27, 2024
38c85ef
build(install): dynamically print internal IPs
AnonymousWP Jun 27, 2024
c5e305e
build(install): don't print subnetmask
AnonymousWP Jun 27, 2024
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
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ services:
context: ./web
restart: always
entrypoint: /usr/src/app/celery-entrypoint.sh
# command: celery -A reNgine worker --autoscale=${MAX_CONCURRENCY},${MIN_CONCURRENCY} -l INFO
volumes:
- ./web:/usr/src/app
- github_repos:/usr/src/github
Expand Down Expand Up @@ -169,7 +168,6 @@ services:
networks:
- rengine_network


networks:
rengine_network:

Expand Down
168 changes: 101 additions & 67 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,120 +1,154 @@
#!/bin/bash

#log messages in different colors
# Define color codes.
# Using `tput setaf` at some places because the variable only works with log/echo

COLOR_BLACK=0
COLOR_RED=1
COLOR_GREEN=2
COLOR_YELLOW=3
COLOR_BLUE=4
COLOR_MAGENTA=5
COLOR_CYAN=6
COLOR_WHITE=7
COLOR_DEFAULT=$COLOR_WHITE # Use white as default for clarity

# Fetch the internal and external IP address so that it can be printed later when the script has finished installing reNgine-ng
external_ip=$(curl -s https://ipecho.net/plain)
internal_ips=$(ip -4 -br addr | awk '$2 == "UP" {print $3} /^lo/ {print $3}' | cut -d'/' -f1)
formatted_ips=""
for ip in $internal_ips; do
formatted_ips="${formatted_ips}https://$ip\n"
done

# Log messages in different colors
log() {
tput setaf "$2"
local color=${2:-$COLOR_DEFAULT} # Use default color if $2 is not set
if [ "$color" -ne $COLOR_DEFAULT ]; then
tput setaf "$color"
fi
printf "$1\r\n"
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
if [ "$(whoami)" != "root" ]
then
log ""
log "Error installing reNgine-ng: please run this script as root!" $COLOR_RED
log "Example: sudo ./install.sh" $COLOR_RED
exit
fi

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

log "\r\nBefore running this script, please make sure Docker is running and you have made changes to the '.env' file." 1
log "Changing the postgres username & password from .env is highly recommended.\r\n" 1
log "\r\nBefore running this script, please make sure Docker is running and you have made changes to the '.env' file." $COLOR_RED
log "Changing the PostgreSQL username & password in the '.env' is highly recommended.\r\n" $COLOR_RED

log "#########################################################################" 4
log "Please note that this installation script is only intended for Linux" 3
log "Only x86_64 platform are supported" 3
log "#########################################################################\r\n" 4
log "Please note that this installation script is only intended for Linux" $COLOR_RED
log "Only x86_64 platform are supported" $COLOR_RED

log ""
tput setaf 1;
read -p "Are you sure you made changes to the '.env' file (y/n)? " answer
case ${answer:0:1} in
y|Y|yes|YES|Yes )
log "Continuing Installation!" 2
log "\nContinuing installation!\n" $COLOR_GREEN
;;
* )
if [ -x "$(command -v nano)" ]; then
log "nano already installed, skipping." 2
if ! command -v nano &> /dev/null; then
. /etc/os-release
case "$ID" in
ubuntu|debian) sudo apt update && sudo apt install -y nano ;;
fedora) sudo dnf install -y nano ;;
centos|rhel) sudo yum install -y nano ;;
arch) sudo pacman -Sy nano ;;
opensuse|suse) sudo zypper install -y nano ;;
*) log "Unsupported Linux distribution. Please install nano manually." $COLOR_RED; exit 1 ;;
esac
[ $? -eq 0 ] && log "nano installed!" $COLOR_GREEN || { log "Failed to install nano." $COLOR_RED; exit 1; }
else
sudo apt update && sudo apt install nano -y
log "nano installed!!!" 2
log "nano already installed, skipping." $COLOR_GREEN
fi
nano .env
;;
esac

log "\r\nInstalling reNgine and its dependencies" 4
log "=========================================================================" 4

log "\r\n#########################################################################" 4
log "Installing curl..." 4

if ! command -v curl 2> /dev/null; then
apt update && apt install curl -y
log "CURL installed!!!" 2
log "Installing reNgine-ng and its dependencies..." $COLOR_CYAN

log "Installing curl..." $COLOR_CYAN

if ! command -v curl &> /dev/null; then
. /etc/os-release
case "$ID" in
ubuntu|debian) sudo apt update && sudo apt install -y curl ;;
fedora) sudo dnf install -y curl ;;
centos|rhel) sudo yum install -y curl ;;
arch) sudo pacman -Sy curl ;;
opensuse|suse) sudo zypper install -y curl ;;
*) log "Unsupported Linux distribution. Please install curl manually." $COLOR_RED; exit 1 ;;
esac
[ $? -eq 0 ] && log "CURL installed!" $COLOR_GREEN || { log "Failed to install CURL." $COLOR_RED; exit 1; }
else
log "CURL already installed, skipping." 2
log "CURL already installed, skipping." $COLOR_GREEN
fi


log "\r\n#########################################################################" 4
log "Installing Docker..." 4

log "Installing Docker..." $COLOR_CYAN
if ! command -v docker 2> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
log "Docker installed!!!" 2
log "Docker installed!" $COLOR_GREEN
else
log "Docker already installed, skipping." 2
log "Docker already installed, skipping." $COLOR_GREEN
fi

log "\r\n#########################################################################" 4
log "Installing Docker Compose" 4

log "Installing Docker Compose..." $COLOR_CYAN
if ! command -v docker compose 2> /dev/null; then
curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
curl -L "https://github.com/docker/compose/releases/latest/download/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
log "Docker Compose installed!!!" 2
log "Docker Compose installed!" $COLOR_GREEN
else
log "Docker Compose already installed, skipping." 2
log "Docker Compose already installed, skipping." $COLOR_GREEN
fi

log "\r\n#########################################################################" 4
log "Installing make" 4

if ! command -v make 2> /dev/null; then
apt install make -y
log "make installed!!!" 2
if ! command -v make &> /dev/null; then
. /etc/os-release
case "$ID" in
ubuntu|debian) sudo apt update && sudo apt install -y make ;;
fedora) sudo dnf install -y make ;;
centos|rhel) sudo yum install -y make ;;
arch) sudo pacman -Sy make ;;
opensuse|suse) sudo zypper install -y make ;;
*) log "Unsupported Linux distribution. Please install make manually." $COLOR_RED; exit 1 ;;
esac
[ $? -eq 0 ] && log "make installed!" $COLOR_GREEN || { log "Failed to install make." $COLOR_RED; exit 1; }
else
log "make already installed, skipping." 2
log "make already installed, skipping." $COLOR_GREEN
fi

log "\r\n#########################################################################" 4
log "Checking Docker status" 4
log "Checking Docker status..." $COLOR_CYAN
if docker info >/dev/null 2>&1; then
log "Docker is running." 2
log "Docker is running." $COLOR_GREEN
else
log "Docker is not running. Please run docker and try again." 1
log "You can run Docker service using: sudo systemctl start docker" 1
log "Docker is not running. Please run Docker and try again." $COLOR_RED
log "You can run Docker service using: sudo systemctl start docker" $COLOR_RED
exit 1
fi

log "\r\n#########################################################################" 4
log "Installing reNgine, please be patient it could take a while" 4
log "Installing reNgine-ng, please be patient as it could take a while..." $COLOR_CYAN
sleep 5

log "\r\n=========================================================================" 5
log "Generating certificates and building docker images" 5
log "=========================================================================" 5
make certs && make build && log "reNgine is built" 2 || { log "reNgine installation failed!!" 1; exit 1; }
log "Generating certificates and building Docker images..." $COLOR_CYAN
make certs && make build && log "reNgine-ng is built" $COLOR_GREEN || { log "reNgine-ng installation failed!" $COLOR_RED; exit 1; }

log "\r\n=========================================================================" 5
log "Docker containers starting, please wait celery container could be long" 5
log "=========================================================================" 5
make up && log "reNgine is installed!!!" 2 || { log "reNgine installation failed!!" 1; exit 1; }
log "Docker containers starting, please wait as Celery container could take a while..." $COLOR_CYAN
sleep 5
make up && log "reNgine-ng is installed!" $COLOR_GREEN || { log "reNgine-ng installation failed!" $COLOR_RED; exit 1; }


log "\r\n#########################################################################" 4
log "Creating an account" 4
log "#########################################################################" 4
log "Creating an account..." $COLOR_CYAN
make username

log "\r\nThank you for installing reNgine, happy recon!!" 2
log "\r\nThank you for installing reNgine-ng, happy recon!" $COLOR_GREEN

log "\r\nIn case you're running this locally, reNgine-ng should be available at one of the following IPs:\n$formatted_ips" $COLOR_GREEN
log "In case you're running this on a server, reNgine-ng should be available at: https://$external_ip/" $COLOR_GREEN
6 changes: 3 additions & 3 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if "%1" == "build" docker compose %COMPOSE_ALL_FILES% build %SERVICES%
:: Generate Username (Use only after make up).
if "%1" == "username" docker compose %COMPOSE_ALL_FILES% exec web python3 manage.py createsuperuser
:: Pull Docker images.
if "%1" == "pull" docker login docker.pkg.github.com & docker-compose %COMPOSE_ALL_FILES% pull
if "%1" == "pull" docker login docker.pkg.github.com & docker compose %COMPOSE_ALL_FILES% pull
:: Down all services.
if "%1" == "down" docker compose %COMPOSE_ALL_FILES% down
:: Stop all services.
Expand All @@ -30,6 +30,6 @@ if "%1" == "logs" docker compose %COMPOSE_ALL_FILES% logs --follow --tail=1000 %
:: Show all Docker images.
if "%1" == "images" docker compose %COMPOSE_ALL_FILES% images %SERVICES%
:: Remove containers and delete volume data.
if "%1" == "prune" docker compose %COMPOSE_ALL_FILES% stop %SERVICES% & docker-compose %COMPOSE_ALL_FILES% rm -f %SERVICES% & docker volume prune -f
if "%1" == "prune" docker compose %COMPOSE_ALL_FILES% stop %SERVICES% & docker compose %COMPOSE_ALL_FILES% rm -f %SERVICES% & docker volume prune -f
:: Show this help.
if "%1" == "help" @echo Make application Docker images and manage containers using Docker Compose files only for windows.
if "%1" == "help" @echo Make application Docker images and manage containers using Docker Compose files only for Windows.
Loading
Loading