2021-01-08 15:10:44 +00:00
|
|
|
defaults = {
|
|
|
|
'apt': {
|
|
|
|
'packages': {
|
|
|
|
'transmission-daemon': {},
|
|
|
|
'transmission-remote-cli': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'icinga2_api': {
|
|
|
|
'transmission': {
|
|
|
|
'services': {
|
|
|
|
'TRANSMISSION PROCESS': {
|
|
|
|
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -a transmission-daemon -c 1:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'transmission': {
|
|
|
|
'config': {
|
|
|
|
'message-level': 2,
|
|
|
|
'peer-port': 51413,
|
|
|
|
'port-forwarding-enabled': False,
|
|
|
|
'rename-partial-files': True,
|
|
|
|
'rpc-authentication-required': False,
|
|
|
|
'rpc-bind-address': '0.0.0.0',
|
|
|
|
'rpc-enabled': True,
|
|
|
|
'rpc-host-whitelist-enabled': False,
|
|
|
|
'rpc-port': 9091,
|
|
|
|
'rpc-url': '/transmission/',
|
|
|
|
'rpc-whitelist-enabled': False,
|
|
|
|
'start-added-torrents': True,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
|
|
|
'iptables/bundle_rules/transmission',
|
|
|
|
)
|
|
|
|
def iptables(metadata):
|
2021-02-15 13:16:35 +00:00
|
|
|
identifiers = metadata.get('transmission/restrict-to', set())
|
|
|
|
rules = set()
|
2021-01-08 15:10:44 +00:00
|
|
|
|
2021-02-15 13:16:35 +00:00
|
|
|
rules.add('iptables_both -A INPUT -p udp --dport {} -j ACCEPT'.format(
|
2021-01-08 16:06:26 +00:00
|
|
|
metadata.get('transmission/config/peer-port'),
|
|
|
|
))
|
2021-02-15 13:16:35 +00:00
|
|
|
rules.add('iptables_both -A INPUT -p tcp --dport {} -j ACCEPT'.format(
|
2021-01-08 15:10:44 +00:00
|
|
|
metadata.get('transmission/config/peer-port'),
|
|
|
|
))
|
|
|
|
|
2021-02-15 13:16:35 +00:00
|
|
|
if identifiers:
|
|
|
|
for identifier in sorted(identifiers):
|
|
|
|
resolved = repo.libs.tools.resolve_identifier(repo, identifier)
|
|
|
|
|
|
|
|
for address in resolved['ipv4']:
|
|
|
|
rules.add('iptables -A INPUT -p tcp -s {} --dport {} -j ACCEPT'.format(
|
|
|
|
address,
|
|
|
|
metadata.get('transmission/config/rpc-port'),
|
|
|
|
))
|
|
|
|
else:
|
|
|
|
rules.add('iptables -A INPUT -p tcp --dport {} -j ACCEPT'.format(
|
2021-01-08 15:10:44 +00:00
|
|
|
metadata.get('transmission/config/rpc-port'),
|
|
|
|
))
|
|
|
|
|
|
|
|
return {
|
|
|
|
'iptables': {
|
|
|
|
'bundle_rules': {
|
2021-02-15 13:16:35 +00:00
|
|
|
'transmission': list(sorted(rules)),
|
2021-01-08 15:10:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
|
|
|
'icinga2_api/transmission/services',
|
|
|
|
)
|
|
|
|
def icinga_web(metadata):
|
|
|
|
port = metadata.get('transmission/config/rpc-port')
|
|
|
|
path = metadata.get('transmission/config/rpc-url')
|
|
|
|
|
|
|
|
return {
|
|
|
|
'icinga2_api': {
|
|
|
|
'transmission': {
|
|
|
|
'services': {
|
|
|
|
'TRANSMISSION WEB INTERFACE': {
|
|
|
|
'command_on_monitored_host': f'/usr/local/share/icinga/plugins/check_http_url_for_string http://127.0.0.1:{port}{path} "Transmission"',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|