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

Add non-interactive installation parameter #973

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ POSTGRES_HOST=db
#
MAX_CONCURRENCY=80
MIN_CONCURRENCY=10

#
# Rengine web interface super user (for non-interactive install)
#
DJANGO_SUPERUSER_USERNAME=rengine
DJANGO_SUPERUSER_EMAIL=rengine@example.com
DJANGO_SUPERUSER_PASSWORD=Sm7IJG.IfHAFw9snSKv
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include .env
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved
.DEFAULT_GOAL:=help

# Credits: https://github.com/sherifabdlnaby/elastdocker/
Expand Down Expand Up @@ -25,7 +26,11 @@ build: ## Build all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} build ${SERVICES}

username: ## Generate Username (Use only after make up).
ifeq ($(isNonInteractive), true)
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser --username ${DJANGO_SUPERUSER_USERNAME} --email ${DJANGO_SUPERUSER_EMAIL} --noinput
else
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser
endif

pull: ## Pull Docker images.
docker login docker.pkg.github.com
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,27 @@ screenshot: {
git clone https://github.com/yogeshojha/rengine && cd rengine
```

1. Edit the dotenv file, **please make sure to change the password for postgresql `POSTGRES_PASSWORD`!**
1. Edit the dotenv file, **please make sure to change the password for postgresql `POSTGRES_PASSWORD`!**
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

```bash
nano .env
```

1. **Optional, only for Non-interactive install**: In the dotenv file, **please make sure to change the super admin informations!**
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

```bash
DJANGO_SUPERUSER_USERNAME=yourUsername
DJANGO_SUPERUSER_EMAIL=YourMail@example.com
DJANGO_SUPERUSER_PASSWORD=yourStrongPassword
```
If you need to carry out a non-interactive installation, you can setup the login, email and password of the web interface admin directly from the .env file (instead of manually setting them from prompts during the installation process). This option can be interesting for automated installation (via ansible, vagrant, etc.).

DJANGO_SUPERUSER_USERNAME: Web interface admin username (Used to login to the web interface).
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

DJANGO_SUPERUSER_EMAIL: Web interface admin email.
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

DJANGO_SUPERUSER_PASSWORD: Web interface admin password (Used to login to the web interface).
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

1. In the dotenv file, you may also modify the Scaling Configurations

```bash
Expand All @@ -344,6 +359,12 @@ screenshot: {
sudo ./install.sh
```

Or for a non-interactive installation, use `-n` argument (make sure you've modified the .env file before launching the installation).
C0wnuts marked this conversation as resolved.
Show resolved Hide resolved

```bash
sudo ./install.sh -n
```

If `install.sh` does not have install permission, please change it, `chmod +x install.sh`

**reNgine can now be accessed from <https://127.0.0.1> or if you're on the VPS <https://your_vps_ip_address>**
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_PORT=${POSTGRES_PORT}
- POSTGRES_HOST=${POSTGRES_HOST}
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD}
# THIS IS A MUST FOR CHECKING UPDATE, EVERYTIME A COMMIT IS MERGED INTO
# MASTER, UPDATE THIS!!! MAJOR.MINOR.PATCH https://semver.org/
- RENGINE_CURRENT_VERSION='2.0.0'
Expand Down
44 changes: 34 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
#!/bin/bash

usageFunction()
{
echo " "
tput setaf 2;
echo "Usage: $0 (-n) (-h)"
echo -e "\t-n Non-interactive installation (Optional)"
echo -e "\t-h Show usage"
exit 1
}

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

isNonInteractive=false
while getopts nh opt; do
case $opt in
n) isNonInteractive=true ;;
h) usageFunction ;;
?) usageFunction ;;
esac
done

if [ $isNonInteractive = false ]; then
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
else
echo "Non-interactive installation parameter set. Installation begins."
fi

echo " "
tput setaf 3;
Expand Down Expand Up @@ -119,7 +143,7 @@ if [ "${failed}" -eq 0 ]; then
echo "#########################################################################"
echo "Creating an account"
echo "#########################################################################"
make username
make username isNonInteractive=$isNonInteractive

tput setaf 2 && printf "\n%s\n" "Thank you for installing reNgine, happy recon!!"
else
Expand Down