main #1

Closed
othman.suseno wants to merge 25 commits from main into development
358 changed files with 2900 additions and 368 deletions

View File

@@ -0,0 +1,226 @@
# PostgreSQL Migration Guide
## Overview
AtlasOS now supports both SQLite and PostgreSQL databases. You can switch between them by changing the database connection string.
## Quick Start
### Using PostgreSQL
Set the `ATLAS_DB_CONN` environment variable to a PostgreSQL connection string:
```bash
export ATLAS_DB_CONN="postgres://username:password@localhost:5432/atlas?sslmode=disable"
./atlas-api
```
### Using SQLite (Default)
Set the `ATLAS_DB_PATH` environment variable to a file path:
```bash
export ATLAS_DB_PATH="/var/lib/atlas/atlas.db"
./atlas-api
```
Or use the connection string format:
```bash
export ATLAS_DB_CONN="sqlite:///var/lib/atlas/atlas.db"
./atlas-api
```
## Connection String Formats
### PostgreSQL
```
postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
```
Examples:
- `postgres://user:pass@localhost:5432/atlas`
- `postgres://user:pass@localhost:5432/atlas?sslmode=disable`
- `postgresql://user:pass@db.example.com:5432/atlas?sslmode=require`
### SQLite
- File path: `/var/lib/atlas/atlas.db`
- Connection string: `sqlite:///var/lib/atlas/atlas.db`
## Setup PostgreSQL Database
### 1. Install PostgreSQL
**Ubuntu/Debian:**
```bash
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
```
**CentOS/RHEL:**
```bash
sudo yum install postgresql-server postgresql-contrib
sudo postgresql-setup initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql
```
### 2. Create Database and User
```bash
# Switch to postgres user
sudo -u postgres psql
# Create database
CREATE DATABASE atlas;
# Create user
CREATE USER atlas_user WITH PASSWORD 'your_secure_password';
# Grant privileges
GRANT ALL PRIVILEGES ON DATABASE atlas TO atlas_user;
# Exit
\q
```
### 3. Configure AtlasOS
Update your systemd service file (`/etc/systemd/system/atlas-api.service`):
```ini
[Service]
Environment="ATLAS_DB_CONN=postgres://atlas_user:your_secure_password@localhost:5432/atlas?sslmode=disable"
```
Or update `/etc/atlas/atlas.conf`:
```bash
# PostgreSQL connection string
ATLAS_DB_CONN=postgres://atlas_user:your_secure_password@localhost:5432/atlas?sslmode=disable
```
### 4. Restart Service
```bash
sudo systemctl daemon-reload
sudo systemctl restart atlas-api
```
## Migration from SQLite to PostgreSQL
### Option 1: Fresh Start (Recommended for new installations)
1. Set up PostgreSQL database (see above)
2. Update connection string
3. Restart service - tables will be created automatically
### Option 2: Data Migration
If you have existing SQLite data:
1. **Export from SQLite:**
```bash
sqlite3 /var/lib/atlas/atlas.db .dump > atlas_backup.sql
```
2. **Convert SQL to PostgreSQL format:**
- Replace `INTEGER` with `BOOLEAN` for boolean fields
- Replace `TEXT` with `VARCHAR(255)` or `TEXT` as appropriate
- Update timestamp formats
3. **Import to PostgreSQL:**
```bash
psql -U atlas_user -d atlas < converted_backup.sql
```
## Rebuilding the Application
### 1. Install PostgreSQL Development Libraries
**Ubuntu/Debian:**
```bash
sudo apt-get install libpq-dev
```
**CentOS/RHEL:**
```bash
sudo yum install postgresql-devel
```
### 2. Update Dependencies
```bash
go mod tidy
```
### 3. Build
```bash
go build -o atlas-api ./cmd/atlas-api
go build -o atlas-tui ./cmd/atlas-tui
```
Or use the installer:
```bash
sudo ./installer/install.sh
```
## Environment Variables
| Variable | Description | Example |
|----------|-------------|---------|
| `ATLAS_DB_CONN` | Database connection string (takes precedence) | `postgres://user:pass@host:5432/db` |
| `ATLAS_DB_PATH` | SQLite database path (fallback if `ATLAS_DB_CONN` not set) | `/var/lib/atlas/atlas.db` |
## Troubleshooting
### Connection Refused
- Check PostgreSQL is running: `sudo systemctl status postgresql`
- Verify connection string format
- Check firewall rules for port 5432
### Authentication Failed
- Verify username and password
- Check `pg_hba.conf` for authentication settings
- Ensure user has proper permissions
### Database Not Found
- Verify database exists: `psql -l`
- Check database name in connection string
### SSL Mode Errors
- For local connections, use `?sslmode=disable`
- For production, configure SSL properly
## Performance Considerations
### PostgreSQL Advantages
- Better concurrency (multiple writers)
- Advanced query optimization
- Better for high-traffic scenarios
- Supports replication and clustering
### SQLite Advantages
- Zero configuration
- Single file deployment
- Lower resource usage
- Perfect for small deployments
## Schema Differences
The application automatically handles schema differences:
- **SQLite**: Uses `INTEGER` for booleans, `TEXT` for strings
- **PostgreSQL**: Uses `BOOLEAN` for booleans, `VARCHAR/TEXT` for strings
The migration system creates the appropriate schema based on the database type.

3
go.mod
View File

@@ -4,7 +4,9 @@ go 1.24.4
require ( require (
github.com/golang-jwt/jwt/v5 v5.3.0 github.com/golang-jwt/jwt/v5 v5.3.0
github.com/lib/pq v1.10.9
golang.org/x/crypto v0.46.0 golang.org/x/crypto v0.46.0
modernc.org/sqlite v1.40.1
) )
require ( require (
@@ -18,5 +20,4 @@ require (
modernc.org/libc v1.66.10 // indirect modernc.org/libc v1.66.10 // indirect
modernc.org/mathutil v1.7.1 // indirect modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.40.1 // indirect
) )

28
go.sum
View File

@@ -2,8 +2,12 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
@@ -14,14 +18,38 @@ golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4=
modernc.org/cc/v4 v4.26.5/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A=
modernc.org/ccgo/v4 v4.28.1/go.mod h1:uD+4RnfrVgE6ec9NGguUNdhqzNIeeomeXf6CL0GTE5Q=
modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A= modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A=
modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I= modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY=
modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

View File

@@ -0,0 +1,34 @@
AtlasOS Bundle for Ubuntu 24.04 (Noble Numbat)
Generated: 2025-12-15 14:23:10 UTC
Packages: 21 main packages + dependencies
Main Packages:
build-essential
git
curl
wget
ca-certificates
software-properties-common
apt-transport-https
zfsutils-linux
zfs-zed
zfs-initramfs
samba
samba-common-bin
nfs-kernel-server
rpcbind
targetcli-fb
sqlite3
libsqlite3-dev
golang-go
openssl
net-tools
iproute2
Total .deb files: 326
Installation Instructions:
1. Transfer this entire directory to your airgap system
2. Run: sudo ./installer/install.sh --offline-bundle "/app/atlas/installer/atlas-bundle-ubuntu24.04"
Note: Ensure all .deb files are present before transferring

View File

@@ -0,0 +1,42 @@
# AtlasOS Offline Bundle for Ubuntu 24.04
This bundle contains all required packages and dependencies for installing AtlasOS on an airgap (offline) Ubuntu 24.04 system.
## Contents
- All required .deb packages with dependencies
- Go binary (fallback, if needed)
- Installation manifest
## Usage
1. Transfer this entire directory to your airgap system
2. On the airgap system, run:
```bash
sudo ./installer/install.sh --offline-bundle /path/to/this/directory
```
## Bundle Size
The bundle typically contains:
- ~100-200 .deb packages (including dependencies)
- Total size: ~500MB - 1GB (depending on architecture)
## Verification
Before transferring, verify the bundle:
```bash
# Count .deb files
find . -name "*.deb" | wc -l
# Check manifest
cat MANIFEST.txt
```
## Troubleshooting
If installation fails:
1. Check that all .deb files are present
2. Verify you're on Ubuntu 24.04
3. Check disk space (need at least 2GB free)
4. Review installation logs

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More