paths = { # subpaths of /video
    'capture',
    'encoded',
    'fuse',
    'intros',
    'repair',
    'tmp',
}

directories = {
    '/opt/crs-scripts': {},
}

for path in paths:
    directories[f'/video/{path}'] = {
        'owner': 'voc',
        'group': 'voc',
    }

git_deploy = {
    '/opt/crs-scripts': {
        'repo': 'https://github.com/crs-tools/crs-scripts.git',
        'rev': 'master',
    },
}

files = {
    '/etc/default/crs-worker': {
        'content_type': 'mako',
        'source': 'environment',
        'context': node.metadata.get('voc-tracker-worker'),
    },
}

for worker, script in {
    'recording-scheduler': 'script-A-recording-scheduler.pl',
    'mount4cut': 'script-B-mount4cut.pl',
    'cut-postprocessor': 'script-C-cut-postprocessor.pl',
    'encoding': 'script-D-encoding.pl',
    'postencoding': 'script-E-postencoding-auphonic.pl',
    'postprocessing': 'script-F-postprocessing-upload.pl',
}.items():
    files[f'/etc/systemd/system/crs-{worker}.service'] = {
        'content_type': 'mako',
        'source': 'crs-runner.service',
        'context': {
            'worker': worker,
            'script': script,
        },
        'needs': {
            'file:/etc/default/crs-worker',
        },
        'triggers': {
            'action:systemd-reload',
        },
    }
