diff --git a/docs/configuration.md b/docs/configuration.md index 90e76da..17b615c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -167,11 +167,12 @@ ssl: ### Database Configuration -File metadata storage settings. +File metadata storage settings. Armor supports SQLite, PostgreSQL, and MySQL databases. +#### SQLite Configuration (Default) ```yaml database: - dialect: "sqlite" # Database type (sqlite only) + dialect: "sqlite" # Database type storage: "/var/lib/armor/database/armor.db" logging: false # Enable SQL query logging pool: @@ -180,6 +181,70 @@ database: idle: 10000 # Idle timeout (ms) ``` +#### PostgreSQL Configuration +```yaml +database: + dialect: "postgres" + host: "localhost" + port: 5432 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false + pool: + max: 10 + min: 2 + idle: 30000 +``` + +#### MySQL Configuration +```yaml +database: + dialect: "mysql" + host: "localhost" + port: 3306 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false + pool: + max: 10 + min: 2 + idle: 30000 +``` + +#### PostgreSQL Configuration +```yaml +database: + dialect: "postgres" + host: "localhost" + port: 5432 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false + pool: + max: 10 + min: 2 + idle: 30000 +``` + +#### MySQL Configuration +```yaml +database: + dialect: "mysql" + host: "localhost" + port: 3306 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false + pool: + max: 10 + min: 2 + idle: 30000 +``` + ### Swagger UI Configuration API documentation interface settings. @@ -276,6 +341,14 @@ export ARMOR_SSL_KEY_FILE=/path/to/key.pem export ARMOR_SSL_CERT_FILE=/path/to/cert.pem # Database configuration +export ARMOR_DATABASE_DIALECT=postgres +export ARMOR_DATABASE_HOST=localhost +export ARMOR_DATABASE_PORT=5432 +export ARMOR_DATABASE_NAME=armor_db +export ARMOR_DATABASE_USERNAME=armor_user +export ARMOR_DATABASE_PASSWORD=armor_password + +# SQLite specific export ARMOR_DATABASE_STORAGE=/custom/path/database.db # Security configuration @@ -345,10 +418,29 @@ Armor validates configuration on startup and will: - Test with basic auth: `curl -k -u admin:admin123 https://localhost/` **Database Issues** + +**SQLite Issues** - Check SQLite file permissions: `sudo chown armor:armor /var/lib/armor/database/` - Verify disk space available - Test database: `sqlite3 /var/lib/armor/database/armor.db .tables` +**PostgreSQL Issues** +- Check connection: `psql -h localhost -U armor_user -d armor_db` +- Verify schema ownership: `psql -d armor_db -c "\dn+"` +- If ENUM creation fails: `sudo -u postgres psql -d armor_db -c "ALTER SCHEMA public OWNER TO armor_user;"` +- Check PostgreSQL service: `sudo systemctl status postgresql` + +**MySQL Issues** +- Check connection: `mysql -h localhost -u armor_user -p armor_db` +- Verify user privileges: `SHOW GRANTS FOR 'armor_user'@'localhost';` +- Check MySQL service: `sudo systemctl status mysql` + +**General Database Issues** +- Verify database dependencies are installed (`pg` for PostgreSQL, `mysql2` for MySQL) +- Check database service is running +- Verify network connectivity and firewall settings +- Review Armor logs: `sudo journalctl -u armor -f` + --- For more help, see [Support Documentation](../support/) or [open an issue](https://github.com/STARTcloud/armor_private/issues). diff --git a/docs/guides/getting-started.md b/docs/guides/getting-started.md index 2445a3d..3adbc30 100644 --- a/docs/guides/getting-started.md +++ b/docs/guides/getting-started.md @@ -24,7 +24,8 @@ This guide will walk you through setting up Armor for the first time, from insta Before starting, ensure you have: - **Node.js 22+** - Required for running Armor server -- **SQLite3** - For file metadata storage +- **Database** - SQLite3 (default), PostgreSQL, or MySQL for file metadata storage +- **Database Dependencies** - `pg` package for PostgreSQL, `mysql2` for MySQL (install via npm) - **OpenSSL** - For SSL certificate generation - **Network Access** - For HTTPS file serving @@ -55,7 +56,7 @@ cd armor_private npm ci # Configure -cp config.yaml.example config.yaml +cp dev.config.yaml config.yaml # Edit config.yaml with your settings # Start server diff --git a/docs/guides/installation.md b/docs/guides/installation.md index 991cf3f..9f00d0b 100644 --- a/docs/guides/installation.md +++ b/docs/guides/installation.md @@ -197,6 +197,92 @@ ssl: cert_file: "/etc/letsencrypt/live/armor.yourdomain.com/fullchain.pem" ``` +## Database Setup + +Armor supports SQLite (default), PostgreSQL, and MySQL databases. + +### SQLite (Default) + +No additional setup required. SQLite database is created automatically. + +```yaml +database: + dialect: "sqlite" + storage: "/var/lib/armor/database/armor.db" + logging: false +``` + +### PostgreSQL Setup + +#### Install Dependencies + +```bash +# Add PostgreSQL support +npm install pg +``` + +#### Create Database and User + +```bash +# Create database and user +sudo -u postgres createdb armor_db +sudo -u postgres createuser armor_user +sudo -u postgres psql -c "ALTER USER armor_user WITH PASSWORD 'armor_password';" +sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE armor_db TO armor_user;" + +# Critical: Set schema ownership for ENUM creation +sudo -u postgres psql -d armor_db -c "ALTER SCHEMA public OWNER TO armor_user;" +``` + +#### Configure Armor + +```yaml +database: + dialect: "postgres" + host: "localhost" + port: 5432 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false +``` + +### MySQL Setup + +#### Install Dependencies + +```bash +# Add MySQL support +npm install mysql2 +``` + +#### Create Database and User + +```bash +# Connect to MySQL as root +mysql -u root -p + +# Create database and user +CREATE DATABASE armor_db; +CREATE USER 'armor_user'@'localhost' IDENTIFIED BY 'armor_password'; +GRANT ALL PRIVILEGES ON armor_db.* TO 'armor_user'@'localhost'; +FLUSH PRIVILEGES; +EXIT; +``` + +#### Configure Armor + +```yaml +database: + dialect: "mysql" + host: "localhost" + port: 3306 + database: "armor_db" + username: "armor_user" + password: "armor_password" + logging: false +``` + ## Service Configuration ### DEBIAN/Ubuntu (systemd) diff --git a/docs/index.md b/docs/index.md index fa3e1a5..73dcb97 100644 --- a/docs/index.md +++ b/docs/index.md @@ -39,7 +39,7 @@ graph TD B -- File Operations --> C[File System]; B -- Real-time Updates --> D[WebSocket/SSE]; B -- Authentication --> E[JWT/API Keys]; - B -- File Metadata --> F[SQLite Database]; + B -- File Metadata --> F[Database (SQLite/PostgreSQL/MySQL)]; G[CLI Tools] -- HTTP Basic Auth --> B; H[API Clients] -- Bearer Tokens --> B; ```