Diff -- /var/www/vhosts/3dshawn.com/site1/_schema/drift_sense_agent_mode.sql
Diff
/var/www/vhosts/3dshawn.com/site1/_schema/drift_sense_agent_mode.sql
deleted on local at 2026-07-12 01:52:02
Added
+0
lines
Removed
-44
lines
Context
0
unchanged
Blobs
from 14342878e899
to
to
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.| 1 | -- DriftSense -- agent-mode schema extension (Stealth Flavor 2) | |
| 2 | -- | |
| 3 | -- Extends SERVERS with SSH connection details so _agent_scan.pl can | |
| 4 | -- SSH into a monitored host, walk its filesystem via a restricted key, | |
| 5 | -- and pull file content back into the central BLOB_STORE. Monitored | |
| 6 | -- hosts run zero DriftSense code -- only footprint is one authorized_keys | |
| 7 | -- entry with a command-restricted wrapper. | |
| 8 | -- | |
| 9 | -- Idempotent: uses INFORMATION_SCHEMA probes so re-running is safe. | |
| 10 | ||
| 11 | -- Add ssh_* columns to SERVERS if not present. | |
| 12 | -- MariaDB 5.5 doesn't support ALTER TABLE ... ADD COLUMN IF NOT EXISTS, | |
| 13 | -- so we probe first and only fire the ALTER when needed. | |
| 14 | ||
| 15 | DELIMITER $$ | |
| 16 | DROP PROCEDURE IF EXISTS _drift_add_col $$ | |
| 17 | CREATE PROCEDURE _drift_add_col(IN t_name VARCHAR(64), IN c_name VARCHAR(64), IN c_ddl VARCHAR(500)) | |
| 18 | BEGIN | |
| 19 | IF NOT EXISTS ( | |
| 20 | SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS | |
| 21 | WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = t_name AND COLUMN_NAME = c_name | |
| 22 | ) THEN | |
| 23 | SET @sql = CONCAT('ALTER TABLE ', t_name, ' ADD COLUMN ', c_name, ' ', c_ddl); | |
| 24 | PREPARE stmt FROM @sql; | |
| 25 | EXECUTE stmt; | |
| 26 | DEALLOCATE PREPARE stmt; | |
| 27 | END IF; | |
| 28 | END $$ | |
| 29 | DELIMITER ; | |
| 30 | ||
| 31 | CALL _drift_add_col('SERVERS', 'kind', "ENUM('local','ssh_agent') NOT NULL DEFAULT 'local'"); | |
| 32 | CALL _drift_add_col('SERVERS', 'ssh_host', "VARCHAR(255) DEFAULT NULL"); | |
| 33 | CALL _drift_add_col('SERVERS', 'ssh_user', "VARCHAR(64) DEFAULT NULL"); | |
| 34 | CALL _drift_add_col('SERVERS', 'ssh_port', "INT UNSIGNED NOT NULL DEFAULT 22"); | |
| 35 | CALL _drift_add_col('SERVERS', 'ssh_key_path', "VARCHAR(500) DEFAULT NULL"); | |
| 36 | CALL _drift_add_col('SERVERS', 'ssh_options', "VARCHAR(500) DEFAULT NULL"); | |
| 37 | CALL _drift_add_col('SERVERS', 'last_agent_scan_at', "DATETIME DEFAULT NULL"); | |
| 38 | CALL _drift_add_col('SERVERS', 'last_agent_error', "VARCHAR(500) DEFAULT NULL"); | |
| 39 | ||
| 40 | DROP PROCEDURE _drift_add_col; | |
| 41 | ||
| 42 | -- Ensure the local server exists with kind='local' (the default we've | |
| 43 | -- been using since v2 install). | |
| 44 | UPDATE SERVERS SET kind = 'local' WHERE server_id = 1 AND kind IS NULL; |