feat: automated setup.sh, OCIR login helper with encrypted credentials, README updates
This commit is contained in:
@@ -182,26 +182,47 @@ us-ashburn-1.ocir.io/idi1o0a010nx/oci-cis-agent:latest
|
||||
|
||||
## Deployment
|
||||
|
||||
### Quick Setup (recommended)
|
||||
|
||||
One command — handles authentication, pull, and container startup automatically:
|
||||
|
||||
```bash
|
||||
bash setup.sh
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
========================================
|
||||
A-Team Security Agent — Setup
|
||||
========================================
|
||||
|
||||
Authenticating...
|
||||
Authenticated.
|
||||
Pulling image...
|
||||
Starting container on port 8080...
|
||||
|
||||
========================================
|
||||
Setup Complete!
|
||||
========================================
|
||||
|
||||
URL: http://localhost:8080
|
||||
User: admin
|
||||
Password: admin123
|
||||
|
||||
You will be prompted to change the password on first login.
|
||||
========================================
|
||||
```
|
||||
|
||||
Custom port: `PORT=9090 bash setup.sh`
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Docker installed
|
||||
- Access to the OCI Container Registry (OCIR)
|
||||
- OCI API Key pair (private `.pem` key + fingerprint) for application configuration
|
||||
|
||||
### OCIR Authentication
|
||||
|
||||
```bash
|
||||
docker login us-ashburn-1.ocir.io
|
||||
```
|
||||
|
||||
- **Username:** `<namespace>/oracleidentitycloudservice/<email>`
|
||||
- **Password:** Auth Token (generate in OCI Console > Profile > Auth Tokens)
|
||||
- Python 3 with `cryptography` package (auto-installed by setup.sh if missing)
|
||||
|
||||
---
|
||||
|
||||
### Option 1 — Docker (any machine)
|
||||
|
||||
Run on any machine with Docker installed (Linux, macOS, Windows).
|
||||
### Alternative: Manual Docker Run
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
@@ -214,7 +235,7 @@ docker run -d \
|
||||
us-ashburn-1.ocir.io/idi1o0a010nx/oci-cis-agent:latest
|
||||
```
|
||||
|
||||
Access: `http://localhost:8080`
|
||||
> Requires OCIR authentication: `docker login us-ashburn-1.ocir.io`
|
||||
|
||||
---
|
||||
|
||||
|
||||
97
distribution/setup.sh
Executable file
97
distribution/setup.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================================
|
||||
# A-Team Security — Infrastructure & Security Agent Engineer
|
||||
# One-command setup: login → pull → run
|
||||
# ============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE="us-ashburn-1.ocir.io/idi1o0a010nx/oci-cis-agent:latest"
|
||||
CONTAINER_NAME="oci-cis-agent"
|
||||
PORT="${PORT:-8080}"
|
||||
|
||||
# ── Embedded credentials (read-only, scoped to this image only) ────────────
|
||||
_R="us-ashburn-1.ocir.io"
|
||||
_U="idi1o0a010nx/oracleidentitycloudservice/gustavo.nogueira@oracle.com"
|
||||
_K() { python3 -c "
|
||||
import base64 as b,hashlib as h
|
||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.fernet import Fernet
|
||||
k=PBKDF2HMAC(algorithm=hashes.SHA256(),length=32,salt=b'oci-cis-agent-ocir-v1',iterations=600000)
|
||||
f=Fernet(b.urlsafe_b64encode(k.derive(b'$(printf '%s' "YXRlYW0tc2VjdXJpdHktMjAyNg==" | base64 -d)')))
|
||||
print(f.decrypt(b'gAAAAABp0CYOb2bj1neOKUS8L_OOaNTcqEcgWouGiHtn96LDoOgpzJ1YeITNSq5tOqJZRW2JcEMZRWsbC3rc0tAoGsvM2o_Fh_q4RIoyP6nzJ0B1JLBRqnk=').decode(),end='')
|
||||
"; }
|
||||
|
||||
echo "========================================"
|
||||
echo " A-Team Security Agent — Setup"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# ── Check dependencies ─────────────────────────────────────────────────────
|
||||
for cmd in docker python3; do
|
||||
if ! command -v $cmd &>/dev/null; then
|
||||
echo "Error: $cmd is required but not installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
python3 -c "from cryptography.fernet import Fernet" 2>/dev/null || {
|
||||
echo "Installing cryptography..."
|
||||
pip3 install cryptography --quiet
|
||||
}
|
||||
|
||||
# ── Stop existing container if running ─────────────────────────────────────
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
echo "Stopping existing container..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# ── Login to OCIR ──────────────────────────────────────────────────────────
|
||||
echo "Authenticating..."
|
||||
_K | docker login "$_R" -u "$_U" --password-stdin >/dev/null 2>&1
|
||||
echo "Authenticated."
|
||||
|
||||
# ── Pull latest image ──────────────────────────────────────────────────────
|
||||
echo "Pulling image..."
|
||||
docker pull "$IMAGE"
|
||||
|
||||
# ── Generate APP_SECRET if not set ─────────────────────────────────────────
|
||||
if [ -z "${APP_SECRET:-}" ]; then
|
||||
APP_SECRET=$(openssl rand -hex 64)
|
||||
echo "Generated APP_SECRET."
|
||||
fi
|
||||
|
||||
# ── Run container ──────────────────────────────────────────────────────────
|
||||
echo "Starting container on port $PORT..."
|
||||
docker run -d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
-p "${PORT}:8080" \
|
||||
-v agent-data:/data \
|
||||
-e APP_SECRET="$APP_SECRET" \
|
||||
-e TZ="${TZ:-America/Sao_Paulo}" \
|
||||
--restart unless-stopped \
|
||||
"$IMAGE"
|
||||
|
||||
# ── Wait for startup ──────────────────────────────────────────────────────
|
||||
echo "Waiting for application to start..."
|
||||
for i in $(seq 1 30); do
|
||||
if curl -sf "http://localhost:${PORT}/api/health" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# ── Show access info ───────────────────────────────────────────────────────
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Setup Complete!"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
echo " URL: http://localhost:${PORT}"
|
||||
echo " User: admin"
|
||||
echo " Password: $(docker logs "$CONTAINER_NAME" 2>&1 | grep 'password:' | head -1 | sed 's/.*password: //')"
|
||||
echo ""
|
||||
echo " You will be prompted to change the password on first login."
|
||||
echo ""
|
||||
echo "========================================"
|
||||
Reference in New Issue
Block a user