Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 8 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This repository combines all the OSH modules and dependencies to deploy the OSH
- [Java 21](https://www.oracle.com/java/technologies/downloads/#java21)
- [Oakridge Build Node Repository](https://github.com/Botts-Innovative-Research/osh-oakridge-buildnode)
- Node v22
- [Docker](https://docs.docker.com/get-docker/) (Required to run the PostGIS database system)

## Installation
Clone the repository and update all submodules recursively
Expand Down Expand Up @@ -45,63 +44,25 @@ After the build completes, it can be located in `build/distributions/`

Option 1: Command Line
```bash
# Note: Replace <version> with the current version, e.g. 3.0.0
unzip build/distributions/osh-node-oscar-<version>.zip
cd osh-node-oscar-<version>/osh-node-oscar-<version>
unzip build/distributions/osh-node-oscar-1.0.zip
cd osh-node-oscar-1.0/osh-node-oscar-1.0
```
```bash
# Note: Replace <version> with the current version, e.g. 3.0.0
tar -xf build/distributions/osh-node-oscar-<version>.zip
cd osh-node-oscar-<version>/osh-node-oscar-<version>
tar -xf build/distributions/osh-node-oscar-1.0.zip
cd osh-node-oscar-1.0/osh-node-oscar-1.0
```
Option 2: Use File Explorer
1. Navigate to `path/to/osh-oakridge-buildnode/build/distributions/`
2. Right-click `osh-node-oscar-<version>.zip` (where `<version>` is the current release version, e.g. `3.0.0`).
2. Right-click `osh-node-oscar-1.0.zip`.
3. Select **Extract All..**
4. Choose your destination, (or leave the default) and extract.
1. Launch the OSH node and PostGIS Database:
The database management system is handled through Docker. The default launch scripts automatically build and run a PostGIS container using the `Dockerfile` located in `dist/release/postgis`, and then start the OSH node.
Run the launch script, `launch-all.sh` (or `launch.sh` within the `osh-node-oscar` folder directly if the database is already running) for linux, `launch-all-arm.sh` (or `launch-arm.sh` if it exists) for mac, and `launch-all.bat` (or `launch.bat`) for windows.
1. Launch the OSH node:
Run the launch script, "launch.sh" for linux/mac and "launch.bat" for windows.
2. Access the OSH Node
- Remote: **[ip-address]:8282/sensorhub/admin**
- Locally: **http://localhost:8282/sensorhub/admin**

### First-Time Setup
On first boot, OSCAR enters an **Uninitialized State** and requires configuration via a Setup Wizard.
1. Navigate to `http://localhost:8282/` or `http://localhost:8282/sensorhub/admin`.
2. You will be automatically redirected to the **Setup Wizard**.
3. **Create an Admin Password**: Set a strong password for the `admin` account.
4. **Configure TOTP**:
- Scan the displayed QR code with an authenticator app (Google Authenticator, Authy, etc.).
- **Important**: Save the secret key shown in the wizard!
- Use the **Test Code** form to verify your setup before proceeding.
5. Once complete, you will be redirected to the Admin UI login.

### Logging In
After initialization, use the following credentials:
- **Username**: `admin`
- **Password**: The password you set during the Setup Wizard.
- **Two-Factor Authentication**:
- If your browser or client supports it, enter your password as usual and provide the 6-digit TOTP code when prompted.
- If you are prompted for a single login by the browser and can't provide a TOTP code separately, enter your password followed by a colon and the code (e.g., `mypassword:123456`).

**Language Selection**
The user can select different languages for the Admin UI by using the language drop-down menu located in the top right corner of the Admin UI toolbar. Selecting a new language will instantly switch the UI localization.

**Two-Factor Authentication (2FA)**
2FA is mandatory for the administrator account and can be configured for other users to add an extra layer of security. To set this up for additional users:
1. Log in to the Admin UI as `admin`.
2. Navigate to the **Security** section.
3. Edit a user profile and set up Two-Factor Authentication. A popup window will appear with a QR code generated locally on the server.
4. Scan the QR code with an authenticator app (like Google Authenticator or Authy) to complete the setup.

**Importing/Exporting Lane Configurations via CSV**
Configurations for Lane Systems can be bulk managed via spreadsheet (CSV).
1. Log in to the Admin UI.
2. Navigate to **Services -> OSCAR Service**.
3. Within the configuration form for the OSCAR service, locate the property for spreadsheet configuration (`spreadsheetConfigPath`).
4. To export, click the download button to retrieve the current configurations as a CSV file.
5. To import, upload your modified CSV file through the provided upload mechanism in the service configuration to apply new or updated lane setups.
The default credentials to access the OSH Node are admin:admin. This can be changed in the Security section of the admin page.

For documentation on configuring a Lane System on the OSH Admin panel, please refer to the OSCAR Documentation provided in the Google Drive documentation folder.

Expand All @@ -112,12 +73,6 @@ After configuring the Lanes on the OSH Admin Panel, you can navigate to the Clie

For documentation on configuring a server on the OSCAR Client refer to the OSCAR Documentation provided in the Google Drive documentation folder.

## Security and Federation
- [Security Architecture](SECURITY_ARCHITECTURE.md)
- [System Architecture](SYSTEM_ARCHITECTURE.md)
- [Federation Provisioning (API Keys)](docs/FEDERATION_PROVISIONING.md)
- [Tailscale Security and Configuration](docs/TAILSCALE_CONFIGURATION.md)

# Release Checklist
- Version in `build.gradle`
- Version in `dist/config/standard/config.json`
Expand Down
6 changes: 4 additions & 2 deletions dist/config/standard/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"roles": [
"admin"
],
"allow": [],
"allow": [
"fileserver[af72442c-1ce6-4baa-a126-ed41dda26910]"
],
"deny": []
},
{
Expand Down Expand Up @@ -173,7 +175,7 @@
"url": "localhost:5432",
"dbName": "gis",
"login": "postgres",
"password": "",
"password": "postgres",
"idProviderType": "SEQUENTIAL",
"autoCommitPeriod": 10,
"useBatch": false,
Expand Down
31 changes: 6 additions & 25 deletions dist/release/launch-all-arm.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#!/bin/bash

HOST="${DB_HOST:-localhost}"
HOST=localhost
DB_NAME=gis
DB_USER=postgres
RETRY_MAX=20
RETRY_INTERVAL=5
PROJECT_DIR="$(pwd)" # Store the original directory
CONTAINER_NAME=oscar-postgis-container

# Set up DB password secret
if [ -z "$POSTGRES_PASSWORD_FILE" ]; then
export POSTGRES_PASSWORD_FILE="${PROJECT_DIR}/.db_password"
fi

if [ ! -f "$POSTGRES_PASSWORD_FILE" ]; then
echo "Generating new database password..."
openssl rand -base64 32 > "$POSTGRES_PASSWORD_FILE"
fi

#sudo docker rm -f "$CONTAINER_NAME" 2>/dev/null || true

# Create pgdata directory if needed
Expand Down Expand Up @@ -58,11 +48,10 @@ else
--name $CONTAINER_NAME \
-e POSTGRES_DB=$DB_NAME \
-e POSTGRES_USER=$DB_USER \
-e POSTGRES_PASS=$(cat "$POSTGRES_PASSWORD_FILE") \
-e POSTGRES_PASSWORD=postgres \
-e DATADIR=/var/lib/postgresql/data \
-p 5432:5432 \
-v "$(pwd)/pgdata:/var/lib/postgresql/data" \
-v "$POSTGRES_PASSWORD_FILE:/run/secrets/db_password" \
-d \
oscar-postgis-arm || { echo "Failed to start PostGIS container"; exit 1; }
fi
Expand All @@ -71,24 +60,16 @@ fi
echo "Waiting for PostGIS ARM64 (PostgreSQL) to be ready..."

RETRY_COUNT=0
until docker exec -u "$DB_USER" "$CONTAINER_NAME" pg_isready -d "$DB_NAME" > /dev/null 2>&1; do
export PGPASSWORD=postgres # Needed for pg_isready with password

until docker exec "$CONTAINER_NAME" pg_isready -U "$DB_USER" -d "$DB_NAME" > /dev/null 2>&1; do
echo "PostGIS not ready yet, retrying..."
sleep "${RETRY_INTERVAL}"
done

echo "PostGIS (PostgreSQL) is ready! Please wait for OpenSensorHub to start..."

sleep 30

# Final check
until docker exec -u "$DB_USER" "$CONTAINER_NAME" pg_isready -d "$DB_NAME" > /dev/null 2>&1; do
echo "PostGIS still restarting, waiting..."
sleep 5
done

# Export for OSH backend
export DB_HOST="$HOST"
export POSTGRES_PASSWORD_FILE="$POSTGRES_PASSWORD_FILE"
sleep 10

# Launch osh-node-oscar
cd "$PROJECT_DIR/osh-node-oscar" || { echo "Error: osh-node-oscar not found"; exit 1; }
Expand Down
34 changes: 4 additions & 30 deletions dist/release/launch-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setlocal enabledelayedexpansion

REM ==== CONFIG ====
if "%DB_HOST%"=="" (set HOST=localhost) else (set HOST=%DB_HOST%)
set HOST=localhost
set PORT=5432
set DB_NAME=gis
set USER=postgres
Expand All @@ -14,16 +14,6 @@ set IMAGE_NAME=oscar-postgis

echo PROJECT_DIR is: %PROJECT_DIR%

REM Set up DB password secret
if "%POSTGRES_PASSWORD_FILE%"=="" (set "POSTGRES_PASSWORD_FILE=%PROJECT_DIR%\.db_password")

if not exist "%POSTGRES_PASSWORD_FILE%" (
echo Generating new database password...
powershell -Command "$p = New-Object byte[] 32; (New-Object System.Security.Cryptography.RNGCryptoServiceProvider).GetBytes($p); $pwd = [Convert]::ToBase64String($p); [System.IO.File]::WriteAllText(\"%POSTGRES_PASSWORD_FILE:\=\\%\", $pwd)"
)

set /p DB_PASSWORD=<"%POSTGRES_PASSWORD_FILE%"

where docker >nul 2>&1
if %errorlevel% neq 0 (
echo ERROR: Docker is not installed or not in PATH.
Expand Down Expand Up @@ -71,10 +61,9 @@ if defined CONTAINER_EXISTS (
--name %CONTAINER_NAME% ^
-e POSTGRES_DB=%DB_NAME% ^
-e POSTGRES_USER=%USER% ^
-e POSTGRES_PASSWORD_FILE=/run/secrets/db_password ^
-e POSTGRES_PASSWORD=postgres ^
-p %PORT%:5432 ^
-v "%PROJECT_DIR%\pgdata:/var/lib/postgresql/data" ^
-v "%POSTGRES_PASSWORD_FILE%:/run/secrets/db_password" ^
-d ^
%IMAGE_NAME%

Expand All @@ -89,7 +78,7 @@ echo Waiting for PostGIS database to become ready...
set RETRY_COUNT=0

:wait_loop
docker exec -u %USER% %CONTAINER_NAME% pg_isready -d %DB_NAME% >nul 2>&1
docker exec %CONTAINER_NAME% pg_isready -U %USER% -d %DB_NAME% >nul 2>&1
if %errorlevel% equ 0 (
echo Received OK from PostGIS. Please wait for initialization...
goto after_wait
Expand All @@ -108,25 +97,10 @@ goto wait_loop

:after_wait

timeout /t 30 >nul

:final_wait_loop
docker exec -u %USER% %CONTAINER_NAME% pg_isready -d %DB_NAME% >nul 2>&1
if %errorlevel% equ 0 (
goto after_final_wait
)
echo PostGIS still restarting, waiting...
timeout /t 5 >nul
goto final_wait_loop

:after_final_wait
timeout /t 10 >nul

echo PostGIS database is ready!

REM Export for OSH backend
set DB_HOST=%HOST%
set POSTGRES_PASSWORD_FILE=%POSTGRES_PASSWORD_FILE%

cd "%PROJECT_DIR%\osh-node-oscar"
if %errorlevel% neq 0 (
echo ERROR: osh-node-oscar directory not found.
Expand Down
31 changes: 6 additions & 25 deletions dist/release/launch-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

HOST="${DB_HOST:-localhost}"
HOST="localhost"
PORT="5432"
DB_NAME="gis"
DB_USER="postgres"
Expand All @@ -9,16 +9,6 @@ RETRY_INTERVAL=5
PROJECT_DIR="$(pwd)" # Store the original directory
CONTAINER_NAME="oscar-postgis-container"

# Set up DB password secret
if [ -z "$POSTGRES_PASSWORD_FILE" ]; then
export POSTGRES_PASSWORD_FILE="${PROJECT_DIR}/.db_password"
fi

if [ ! -f "$POSTGRES_PASSWORD_FILE" ]; then
echo "Generating new database password..."
openssl rand -base64 32 > "$POSTGRES_PASSWORD_FILE"
fi

#docker rm -f "$CONTAINER_NAME" 2>/dev/null || true

# Create pgdata directory if needed
Expand Down Expand Up @@ -61,10 +51,9 @@ else
--name "$CONTAINER_NAME" \
-e POSTGRES_DB="$DB_NAME" \
-e POSTGRES_USER="$DB_USER" \
-e POSTGRES_PASSWORD_FILE="/run/secrets/db_password" \
-e POSTGRES_PASSWORD="postgres" \
-p $PORT:5432 \
-v "${PROJECT_DIR}/pgdata:/var/lib/postgresql/data" \
-v "$POSTGRES_PASSWORD_FILE:/run/secrets/db_password" \
-d \
oscar-postgis || { echo "Failed to start PostGIS container"; exit 1; }
fi
Expand All @@ -73,24 +62,16 @@ fi
echo "Waiting for PostGIS (PostgreSQL) to be ready..."

RETRY_COUNT=0
until docker exec -u "$DB_USER" "$CONTAINER_NAME" pg_isready -d "$DB_NAME" > /dev/null 2>&1; do
export PGPASSWORD=postgres # Needed for pg_isready with password

until docker exec "$CONTAINER_NAME" pg_isready -U "$DB_USER" -d "$DB_NAME" > /dev/null 2>&1; do
echo "PostGIS not ready yet, retrying..."
sleep "${RETRY_INTERVAL}"
done

echo "PostGIS (PostgreSQL) is ready! Please wait for OpenSensorHub to start..."

sleep 30

# Final check
until docker exec -u "$DB_USER" "$CONTAINER_NAME" pg_isready -d "$DB_NAME" > /dev/null 2>&1; do
echo "PostGIS still restarting, waiting..."
sleep 5
done

# Export for OSH backend
export DB_HOST="$HOST"
export POSTGRES_PASSWORD_FILE="$POSTGRES_PASSWORD_FILE"
sleep 10

# Launch osh-node-oscar
cd "$PROJECT_DIR/osh-node-oscar" || { echo "Error: osh-node-oscar not found"; exit 1; }
Expand Down
11 changes: 1 addition & 10 deletions dist/release/postgis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
FROM postgis/postgis:16-3.4

# Install fonts as required by AI_CONTRIBUTING_RULES.md
RUN apt-get update && apt-get install -y fonts-freefont-ttf && rm -rf /var/lib/apt/lists/*

COPY init-extensions.sql /docker-entrypoint-initdb.d/init-extensions.sql

# Generate self-signed certificate for SSL support
RUN openssl req -new -x509 -days 365 -nodes -text -out /var/lib/postgresql/server.crt \
-keyout /var/lib/postgresql/server.key -subj "/CN=oscar-postgis" \
&& chmod 600 /var/lib/postgresql/server.key \
&& chown postgres:postgres /var/lib/postgresql/server.key /var/lib/postgresql/server.crt

ENV POSTGRES_INITDB_ARGS="--auth-local=trust --auth-host=scram-sha-256 -c max_parallel_workers_per_gather=0 -c max_parallel_workers=0 -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key"
ENV POSTGRES_INITDB_ARGS="-c max_parallel_workers_per_gather=0 -c max_parallel_workers=0"
11 changes: 2 additions & 9 deletions dist/release/postgis/Dockerfile-arm64
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
FROM kartoza/postgis:16-3.4

# Install fonts as required by AI_CONTRIBUTING_RULES.md
RUN apt-get update && apt-get install -y fonts-freefont-ttf && rm -rf /var/lib/apt/lists/*
RUN echo "host all all all md5" >> /etc/postgresql/16/main/pg_hba.conf

COPY init-extensions.sql /docker-entrypoint-initdb.d/init-extensions.sql

# Generate self-signed certificate for SSL support
RUN openssl req -new -x509 -days 365 -nodes -text -out /var/lib/postgresql/server.crt \
-keyout /var/lib/postgresql/server.key -subj "/CN=oscar-postgis" \
&& chmod 600 /var/lib/postgresql/server.key \
&& chown postgres:postgres /var/lib/postgresql/server.key /var/lib/postgresql/server.crt

ENV POSTGRES_INITDB_ARGS="--auth-local=trust --auth-host=scram-sha-256 -c max_parallel_workers_per_gather=0 -c max_parallel_workers=0 -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key"
ENV POSTGRES_INITDB_ARGS="-c max_parallel_workers_per_gather=0 -c max_parallel_workers=0"
4 changes: 0 additions & 4 deletions dist/release/postgis/init-extensions.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
ALTER SYSTEM SET max_connections = 1024;
ALTER SYSTEM SET ssl = 'on';
ALTER SYSTEM SET ssl_cert_file = '/var/lib/postgresql/server.crt';
ALTER SYSTEM SET ssl_key_file = '/var/lib/postgresql/server.key';

\connect gis;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS btree_gist;
Expand Down
15 changes: 1 addition & 14 deletions dist/release/postgis/run-postgis-arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,13 @@ if [ ! -d "$(pwd)/pgdata" ]; then
mkdir -p "$(pwd)/pgdata"
fi

# Set up DB password secret
PROJECT_DIR="$(pwd)"
if [ -z "$POSTGRES_PASSWORD_FILE" ]; then
export POSTGRES_PASSWORD_FILE="${PROJECT_DIR}/.db_password"
fi

if [ ! -f "$POSTGRES_PASSWORD_FILE" ]; then
echo "Generating new database password..."
openssl rand -base64 32 > "$POSTGRES_PASSWORD_FILE"
fi

docker build . --file=Dockerfile-arm64 --tag=oscar-postgis-arm
docker run \
-e PG_MAX_CONNECTIONS=500 \
-e POSTGRES_DB=gis \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASS=$(cat "$POSTGRES_PASSWORD_FILE") \
-e POSTGRES_PASSWORD=postgres \
-e DATADIR=/var/lib/postgresql/data \
-p 5432:5432 \
-v "$(pwd)/pgdata:/var/lib/postgresql/data" \
-v "$POSTGRES_PASSWORD_FILE:/run/secrets/db_password" \
-d \
oscar-postgis-arm
Loading