-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.sh
More file actions
executable file
·53 lines (43 loc) · 1.54 KB
/
Copy pathstartup.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.54 KB
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
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Docker startup script for MetAIsploit Assistant
# Poetry is installed and dependencies are up to date from Dockerfile build.
set -e
echo "Starting MetAIsploit Assistant..."
# Ensure models directory exists
mkdir -p /app/models
# Initialize database service
if [ ! -f "/root/.msf4/initialized" ]; then
echo "Initializing Metasploit database..."
mkdir -p /root/.msf4
touch /root/.msf4/initialized
# Wait for database to be ready
echo "Waiting for database to be ready..."
until PGPASSWORD=$POSTGRES_PASSWORD pg_isready -h db -U $POSTGRES_USER -d $POSTGRES_DB; do
echo "Waiting for database..."
sleep 2
done
# Initialize database
echo "Running database initialization..."
cd /usr/src/metasploit-framework
./msfconsole -q -x "db_connect ${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}; exit"
echo "Database initialization complete"
fi
# Check if models are available, if not try to download
if [ ! "$(ls -A /app/models)" ]; then
echo "No models found, attempting to download..."
poetry run init || echo "Model download failed, continuing..."
fi
# Start the database service
echo "Starting Metasploit database service..."
service metasploit-db start
# Wait for database service to be ready
echo "Waiting for database service to be ready..."
sleep 5
# Default to chat mode, but allow override via CMD
if [ $# -eq 0 ]; then
echo "Starting interactive chat mode..."
exec poetry run chat
else
echo "Running custom command: $@"
exec poetry run "$@"
fi