diff --git a/bundles/steam-chat-logger/items.py b/bundles/steam-chat-logger/items.py new file mode 100644 index 0000000..a91efcd --- /dev/null +++ b/bundles/steam-chat-logger/items.py @@ -0,0 +1,41 @@ +directories = { + '/opt/steam_chat_logger': { + 'owner': 'steam_chat_logger', + }, + '/var/lib/steam_chat_logger': { + 'owner': 'steam_chat_logger', + 'mode': '0770', + 'needs': [ + 'zfs_dataset:tank/steam-chat-logger' + ], + }, +} + +git_deploy = { + '/opt/steam_chat_logger': { + 'repo': 'https://git.sublimity.de/cronekorkn/steam_chat_logger.git', + 'rev': 'master', + } +} + +pkg_pip = { + 'steam': {}, + 'beautifulsoup4': {}, + 'pytz': {}, + 'pg8000': {}, +} + + +# TODO +''' +CREATE TABLE IF NOT EXISTS messages ( + id SERIAL PRIMARY KEY, + checksum VARCHAR(64) UNIQUE NOT NULL, + from_url VARCHAR(255) NOT NULL, + from_name VARCHAR(255) NOT NULL, + to_url VARCHAR(255) NOT NULL, + to_name VARCHAR(255) NOT NULL, + date TIMESTAMP WITH TIME ZONE NOT NULL, + message TEXT NOT NULL +) +''' diff --git a/bundles/steam-chat-logger/metadata.py b/bundles/steam-chat-logger/metadata.py new file mode 100644 index 0000000..6b98310 --- /dev/null +++ b/bundles/steam-chat-logger/metadata.py @@ -0,0 +1,46 @@ +defaults = { + 'postgresql': { + 'roles': { + 'steam_chat_logger': { + 'password': repo.vault.password_for(f'{node.name} postgresql steam_chat_logger'), + }, + }, + 'databases': { + 'steam_chat_logger': { + 'owner': 'steam_chat_logger', + }, + }, + }, + 'users': { + 'steam_chat_logger': {}, + }, + 'zfs': { + 'datasets': { + 'tank/steam-chat-logger': { + 'mountpoint': '/var/lib/steam_chat_logger', + }, + }, + }, +} + + +@metadata_reactor.provides( + 'systemd-timers/steam-chat-logger', +) +def systemd_timer(metadata): + return { + 'systemd-timers': { + f'steam-chat-logger': { + 'command': '/opt/steam_chat_logger/steam_chat_logger.py', + 'when': 'daily', + 'user': 'steam_chat_logger', + 'env': { + 'DB_NAME': 'steam_chat_logger', + 'DB_USER': 'steam_chat_logger', + 'DB_PASSWORD': metadata.get('postgresql/roles/steam_chat_logger/password'), + **metadata.get('steam_chat_logger'), + }, + 'working_dir': '/var/lib/steam_chat_logger', + }, + }, + } diff --git a/bundles/systemd-timers/metadata.py b/bundles/systemd-timers/metadata.py index c5936af..79efde2 100644 --- a/bundles/systemd-timers/metadata.py +++ b/bundles/systemd-timers/metadata.py @@ -34,6 +34,9 @@ def systemd(metadata): }, }, }) + if config.get('working_dir'): + units[f'{name}.service']['Service']['WorkingDirectory'] = config['working_dir'] + services[f'{name}.timer'] = {} return { diff --git a/nodes/home.server.py b/nodes/home.server.py index 6b1df7f..d22c33f 100644 --- a/nodes/home.server.py +++ b/nodes/home.server.py @@ -24,6 +24,7 @@ 'postgresql', 'redis', 'smartctl', + 'steam-chat-logger', 'raspberrymatic-cert', 'tasmota-charge', 'wireguard', @@ -94,6 +95,14 @@ 'domain': 'homematic.ckn.li', 'node': 'home.homematic', }, + 'steam_chat_logger': { + 'STEAM_USERNAME': 'snake_452', + 'STEAM_ID': 'STEAM_0:0:12376499', + 'STEAM_PASSWORD': '!decrypt:encrypt$gAAAAABiUzERrXVNxzDaDW_4MgEmPtXkMHlTiz5uqCbu-22-2yKHRHMKvuGqAygpGbnwZucZcmZMox9KM89a6qlVKlE1ZPizTA==', + 'IMAP_HOST': 'mail.sublimity.de', + 'IMAP_USER': 'i@ckn.li', + 'IMAP_PASSWORD': '!decrypt:encrypt$gAAAAABiUzcTVRL-Xb4RDjcwciZawYlmOa9Qy_hKz6sVWDlwZqUFLGRD8ERWoFCOWCM22Sq73Gc4nFuAblBB6wpbH5YEltLA6hmROGKpOFhI63ESLFwNgbY=', + }, 'tasmota-charge': { 'phone': { 'ip': '10.0.0.166',