-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-dradis
executable file
·43 lines (37 loc) · 1.31 KB
/
start-dradis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
echo "Sourcing environment..."
source .env
echo "Checking for local data volume directory $DATA_VOLUME"
if [ ! -d "$DATA_VOLUME" ]; then
echo "Creating data volume directory"
mkdir $DATA_VOLUME
echo "Data volume $DATA_VOLUME created"
else
echo "Data volume already exists"
fi
echo "Checking for existing container $CONTAINER_NAME"
if [ ! "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
echo "Starting new container: $CONTAINER_NAME"
docker run --name $CONTAINER_NAME -p $HOST_PORT:3000 -d --volume "$(pwd)/$DATA_VOLUME:/dbdata" ikuturso/dradis
elif [ "$(docker ps | grep $CONTAINER_NAME)" ]; then
echo "Currently running container: $CONTAINER_NAME"
else
echo "Starting existing container: $CONTAINER_NAME"
docker start $CONTAINER_NAME
fi
echo "Waiting for Dradis server to start..."
STATUS=null
while [ "$STATUS" != "302" -a "$STATUS" != "200" ]
do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://0.0.0.0:$HOST_PORT)
done
echo "Opening Dradis in default web browser, wait a few seconds while the Rails server starts"
URL=http://0.0.0.0:$HOST_PORT
if [ "$(uname)" == "Darwin" ]; then
open $URL
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
xdg-open $URL
else
echo "Operating system not supported for browser launch, please go to $URL in your browser"
fi
echo "Happy Hacking :)"