|
|
@ -1,10 +1,11 @@ |
|
|
|
|
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS agents ( |
|
|
|
CREATE TABLE IF NOT EXISTS agents ( |
|
|
|
alias TEXT |
|
|
|
alias TEXT |
|
|
|
, agent_id TEXT NOT NULL UNIQUE |
|
|
|
|
|
|
|
, hostname TEXT NOT NULL |
|
|
|
, hostname TEXT NOT NULL |
|
|
|
, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL |
|
|
|
, id UUID NOT NULL DEFAULT uuid_generate_v4() |
|
|
|
, is_root BOOLEAN NOT NULL DEFAULT 0 |
|
|
|
, is_root BOOLEAN NOT NULL DEFAULT false |
|
|
|
, is_root_allowed BOOLEAN NOT NULL DEFAULT 0 |
|
|
|
, is_root_allowed BOOLEAN NOT NULL DEFAULT false |
|
|
|
, last_active TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
, last_active TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
-- target triplet |
|
|
|
-- target triplet |
|
|
|
, platform TEXT NOT NULL |
|
|
|
, platform TEXT NOT NULL |
|
|
@ -13,47 +14,53 @@ CREATE TABLE IF NOT EXISTS agents ( |
|
|
|
-- is needed to processing requests |
|
|
|
-- is needed to processing requests |
|
|
|
, token TEXT |
|
|
|
, token TEXT |
|
|
|
, username TEXT NOT NULL |
|
|
|
, username TEXT NOT NULL |
|
|
|
|
|
|
|
, PRIMARY KEY(id) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS ip_addrs ( |
|
|
|
CREATE TABLE IF NOT EXISTS ip_addrs ( |
|
|
|
agent_id INTEGER NOT NULL |
|
|
|
agent_id UUID NOT NULL |
|
|
|
, check_ts DATETIME NOT NULL |
|
|
|
, check_ts TIMESTAMP NOT NULL |
|
|
|
, gateway TEXT |
|
|
|
, gateway TEXT |
|
|
|
, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL |
|
|
|
, id SERIAL |
|
|
|
, iface TEXT NOT NULL |
|
|
|
, iface TEXT NOT NULL |
|
|
|
, ip_addr TEXT NOT NULL |
|
|
|
, ip_addr TEXT NOT NULL |
|
|
|
, is_gray BOOLEAN NOT NULL DEFAULT 1 |
|
|
|
, is_gray BOOLEAN NOT NULL DEFAULT true |
|
|
|
, netmask TEXT NOT NULL |
|
|
|
, netmask TEXT NOT NULL |
|
|
|
|
|
|
|
, PRIMARY KEY(id) |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS jobs ( |
|
|
|
CREATE TABLE IF NOT EXISTS jobs ( |
|
|
|
alias TEXT |
|
|
|
alias TEXT |
|
|
|
, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL |
|
|
|
, id SERIAL |
|
|
|
-- Shell, Binary (with program download), Python (with program and python download if not exist), Management |
|
|
|
-- Shell, Binary (with program download), |
|
|
|
|
|
|
|
-- Python (with program and python download if not exist), Management |
|
|
|
, job_type TEXT CHECK(job_type IN ('S','B','P','M')) NOT NULL DEFAULT 'S' |
|
|
|
, job_type TEXT CHECK(job_type IN ('S','B','P','M')) NOT NULL DEFAULT 'S' |
|
|
|
-- Executable type: ALL - no matter, W - windows, L = linux |
|
|
|
-- Executable type: ALL - no matter, W - windows, L = linux |
|
|
|
, exec_type TEXT CHECK(exec_type IN ('ALL', 'W', 'L')) NOT NULL DEFAULT 'L' |
|
|
|
, exec_type TEXT CHECK(exec_type IN ('ALL', 'W', 'L')) NOT NULL DEFAULT 'L' |
|
|
|
, platform TEXT CHECK(platform IN ('x86', 'x64', 'aarch32', 'aarch64')) |
|
|
|
, platform TEXT CHECK(platform IN ('x86', 'x64', 'aarch32', 'aarch64')) |
|
|
|
, data BLOB NOT NULL |
|
|
|
, path TEXT NOT NULL |
|
|
|
|
|
|
|
, PRIMARY KEY(id) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS results ( |
|
|
|
CREATE TABLE IF NOT EXISTS results ( |
|
|
|
agent_id INTEGER NOT NULL |
|
|
|
agent_id UUID NOT NULL |
|
|
|
, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL |
|
|
|
, id SERIAL |
|
|
|
, job_id INTEGER NOT NULL |
|
|
|
, job_id INTEGER NOT NULL |
|
|
|
, result BLOB |
|
|
|
, result TEXT |
|
|
|
-- Queued, Pending, Running, Finished |
|
|
|
-- Queued, Pending, Running, Finished |
|
|
|
, status TEXT CHECK(status IN ('Q', 'P', 'R', 'F')) |
|
|
|
, status TEXT CHECK(status IN ('Q', 'P', 'R', 'F')) |
|
|
|
, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
, FOREIGN KEY(job_id) REFERENCES jobs(id) |
|
|
|
, FOREIGN KEY(job_id) REFERENCES jobs(id) |
|
|
|
|
|
|
|
, PRIMARY KEY(id) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS certificates ( |
|
|
|
CREATE TABLE IF NOT EXISTS certificates ( |
|
|
|
agent_id INTEGER NOT NULL |
|
|
|
agent_id UUID NOT NULL |
|
|
|
, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL |
|
|
|
, id SERIAL |
|
|
|
, is_revoked BOOLEAN NOT NULL DEFAULT FALSE |
|
|
|
, is_revoked BOOLEAN NOT NULL DEFAULT FALSE |
|
|
|
|
|
|
|
, PRIMARY KEY(id) |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
, FOREIGN KEY(agent_id) REFERENCES agents(id) |
|
|
|
); |
|
|
|
); |