mediatomb: make service compatible with the gerbera fork
The duplication of the interface xml tag is needed for the daemon to respect the setting.
This commit is contained in:
parent
420f89ceb2
commit
3bb5cc6849
@ -6,37 +6,42 @@ let
|
|||||||
|
|
||||||
gid = config.ids.gids.mediatomb;
|
gid = config.ids.gids.mediatomb;
|
||||||
cfg = config.services.mediatomb;
|
cfg = config.services.mediatomb;
|
||||||
|
name = cfg.package.pname;
|
||||||
|
pkg = cfg.package;
|
||||||
|
optionYesNo = option: if option then "yes" else "no";
|
||||||
|
|
||||||
mtConf = pkgs.writeText "config.xml" ''
|
mtConf = pkgs.writeText "config.xml" ''
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
|
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
|
||||||
|
<interface>${cfg.interface}</interface>
|
||||||
<server>
|
<server>
|
||||||
<ui enabled="yes" show-tooltips="yes">
|
<ui enabled="yes" show-tooltips="yes">
|
||||||
<accounts enabled="no" session-timeout="30">
|
<accounts enabled="no" session-timeout="30">
|
||||||
<account user="mediatomb" password="mediatomb"/>
|
<account user="${name}" password="${name}"/>
|
||||||
</accounts>
|
</accounts>
|
||||||
</ui>
|
</ui>
|
||||||
<name>${cfg.serverName}</name>
|
<name>${cfg.serverName}</name>
|
||||||
<udn>uuid:${cfg.uuid}</udn>
|
<udn>uuid:${cfg.uuid}</udn>
|
||||||
<home>${cfg.dataDir}</home>
|
<home>${cfg.dataDir}</home>
|
||||||
<webroot>${pkgs.mediatomb}/share/mediatomb/web</webroot>
|
<interface>${cfg.interface}</interface>
|
||||||
|
<webroot>${pkg}/share/${name}/web</webroot>
|
||||||
<storage>
|
<storage>
|
||||||
<sqlite3 enabled="yes">
|
<sqlite3 enabled="yes">
|
||||||
<database-file>mediatomb.db</database-file>
|
<database-file>${name}.db</database-file>
|
||||||
</sqlite3>
|
</sqlite3>
|
||||||
</storage>
|
</storage>
|
||||||
<protocolInfo extend="${if cfg.ps3Support then "yes" else "no"}"/>
|
<protocolInfo extend="${optionYesNo cfg.ps3Support}"/>
|
||||||
${if cfg.dsmSupport then ''
|
${lib.optionalString cfg.dsmSupport ''
|
||||||
<custom-http-headers>
|
<custom-http-headers>
|
||||||
<add header="X-User-Agent: redsonic"/>
|
<add header="X-User-Agent: redsonic"/>
|
||||||
</custom-http-headers>
|
</custom-http-headers>
|
||||||
|
|
||||||
<manufacturerURL>redsonic.com</manufacturerURL>
|
<manufacturerURL>redsonic.com</manufacturerURL>
|
||||||
<modelNumber>105</modelNumber>
|
<modelNumber>105</modelNumber>
|
||||||
'' else ""}
|
''}
|
||||||
${if cfg.tg100Support then ''
|
${optionalString cfg.tg100Support ''
|
||||||
<upnp-string-limit>101</upnp-string-limit>
|
<upnp-string-limit>101</upnp-string-limit>
|
||||||
'' else ""}
|
''}
|
||||||
<extended-runtime-options>
|
<extended-runtime-options>
|
||||||
<mark-played-items enabled="yes" suppress-cds-updates="yes">
|
<mark-played-items enabled="yes" suppress-cds-updates="yes">
|
||||||
<string mode="prepend">*</string>
|
<string mode="prepend">*</string>
|
||||||
@ -48,10 +53,10 @@ let
|
|||||||
</server>
|
</server>
|
||||||
<import hidden-files="no">
|
<import hidden-files="no">
|
||||||
<scripting script-charset="UTF-8">
|
<scripting script-charset="UTF-8">
|
||||||
<common-script>${pkgs.mediatomb}/share/mediatomb/js/common.js</common-script>
|
<common-script>${pkg}/share/${name}/js/common.js</common-script>
|
||||||
<playlist-script>${pkgs.mediatomb}/share/mediatomb/js/playlists.js</playlist-script>
|
<playlist-script>${pkg}/share/${name}/js/playlists.js</playlist-script>
|
||||||
<virtual-layout type="builtin">
|
<virtual-layout type="builtin">
|
||||||
<import-script>${pkgs.mediatomb}/share/mediatomb/js/import.js</import-script>
|
<import-script>${pkg}/share/${name}/js/import.js</import-script>
|
||||||
</virtual-layout>
|
</virtual-layout>
|
||||||
</scripting>
|
</scripting>
|
||||||
<mappings>
|
<mappings>
|
||||||
@ -75,12 +80,12 @@ let
|
|||||||
<map from="flv" to="video/x-flv"/>
|
<map from="flv" to="video/x-flv"/>
|
||||||
<map from="mkv" to="video/x-matroska"/>
|
<map from="mkv" to="video/x-matroska"/>
|
||||||
<map from="mka" to="audio/x-matroska"/>
|
<map from="mka" to="audio/x-matroska"/>
|
||||||
${if cfg.ps3Support then ''
|
${optionalString cfg.ps3Support ''
|
||||||
<map from="avi" to="video/divx"/>
|
<map from="avi" to="video/divx"/>
|
||||||
'' else ""}
|
''}
|
||||||
${if cfg.dsmSupport then ''
|
${optionalString cfg.dsmSupport ''
|
||||||
<map from="avi" to="video/avi"/>
|
<map from="avi" to="video/avi"/>
|
||||||
'' else ""}
|
''}
|
||||||
</extension-mimetype>
|
</extension-mimetype>
|
||||||
<mimetype-upnpclass>
|
<mimetype-upnpclass>
|
||||||
<map from="audio/*" to="object.item.audioItem.musicTrack"/>
|
<map from="audio/*" to="object.item.audioItem.musicTrack"/>
|
||||||
@ -108,10 +113,10 @@ let
|
|||||||
</mappings>
|
</mappings>
|
||||||
<online-content>
|
<online-content>
|
||||||
<YouTube enabled="no" refresh="28800" update-at-start="no" purge-after="604800" racy-content="exclude" format="mp4" hd="no">
|
<YouTube enabled="no" refresh="28800" update-at-start="no" purge-after="604800" racy-content="exclude" format="mp4" hd="no">
|
||||||
<favorites user="mediatomb"/>
|
<favorites user="${name}"/>
|
||||||
<standardfeed feed="most_viewed" time-range="today"/>
|
<standardfeed feed="most_viewed" time-range="today"/>
|
||||||
<playlists user="mediatomb"/>
|
<playlists user="${name}"/>
|
||||||
<uploads user="mediatomb"/>
|
<uploads user="${name}"/>
|
||||||
<standardfeed feed="recently_featured" time-range="today"/>
|
<standardfeed feed="recently_featured" time-range="today"/>
|
||||||
</YouTube>
|
</YouTube>
|
||||||
</online-content>
|
</online-content>
|
||||||
@ -158,18 +163,27 @@ in {
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Whether to enable the mediatomb DLNA server.
|
Whether to enable the Gerbera/Mediatomb DLNA server.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
serverName = mkOption {
|
serverName = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "mediatomb";
|
default = "Gerbera (Mediatomb)";
|
||||||
description = ''
|
description = ''
|
||||||
How to identify the server on the network.
|
How to identify the server on the network.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
example = literalExample "pkgs.mediatomb";
|
||||||
|
default = pkgs.gerbera;
|
||||||
|
description = ''
|
||||||
|
Underlying package to be used with the module (default: pkgs.gerbera).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
ps3Support = mkOption {
|
ps3Support = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -206,20 +220,20 @@ in {
|
|||||||
|
|
||||||
dataDir = mkOption {
|
dataDir = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/var/lib/mediatomb";
|
default = "/var/lib/${name}";
|
||||||
description = ''
|
description = ''
|
||||||
The directory where mediatomb stores its state, data, etc.
|
The directory where ${cfg.serverName} stores its state, data, etc.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
default = "mediatomb";
|
default = "mediatomb";
|
||||||
description = "User account under which mediatomb runs.";
|
description = "User account under which ${name} runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
default = "mediatomb";
|
default = "mediatomb";
|
||||||
description = "Group account under which mediatomb runs.";
|
description = "Group account under which ${name} runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
@ -247,7 +261,10 @@ in {
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Allow mediatomb to create and use its own config file inside ${cfg.dataDir}.
|
Allow ${name} to create and use its own config file inside ${cfg.dataDir}.
|
||||||
|
Deactivated by default, the service then runs with the configuration generated from this module.
|
||||||
|
Otherwise, when enabled, no service configuration is generated. Gerbera/Mediatomb then starts using
|
||||||
|
${cfg.dataDir}/config.xml. It's up to the user to make a correct configuration file.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -257,12 +274,11 @@ in {
|
|||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services.mediatomb = {
|
systemd.services."${name}"= {
|
||||||
description = "MediaTomb media Server";
|
description = "${cfg.serverName} media Server";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ pkgs.mediatomb ];
|
serviceConfig.ExecStart = "${pkg}/bin/${name} -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}";
|
||||||
serviceConfig.ExecStart = "${pkgs.mediatomb}/bin/mediatomb -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}";
|
|
||||||
serviceConfig.User = "${cfg.user}";
|
serviceConfig.User = "${cfg.user}";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -276,11 +292,11 @@ in {
|
|||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
home = "${cfg.dataDir}";
|
home = "${cfg.dataDir}";
|
||||||
createHome = true;
|
createHome = true;
|
||||||
description = "Mediatomb DLNA Server User";
|
description = "${name} DLNA Server User";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall.interfaces."${cfg.interface}" = {
|
||||||
allowedUDPPorts = [ 1900 cfg.port ];
|
allowedUDPPorts = [ 1900 cfg.port ];
|
||||||
allowedTCPPorts = [ cfg.port ];
|
allowedTCPPorts = [ cfg.port ];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user