mirror of
https://github.com/kiddin9/openwrt-packages.git
synced 2025-01-09 20:06:41 +08:00
⛅ Sync 2024-02-04 04:58:47
This commit is contained in:
parent
05ef8bdd83
commit
af31e42962
@ -1,13 +1,9 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Configrure modem bands via mmcli utility
|
||||
LUCI_DEPENDS:=+modemmanager +luci-compat
|
||||
LUCI_DEPENDS:=+luci-proto-modemmanager +luci-app-modeminfo
|
||||
PKG_LICENSE:=GPLv3
|
||||
|
||||
define Package/luci-app-mmconfig/postrm
|
||||
rm -f /etc/config/modemconfig
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require fs';
|
||||
'require ui';
|
||||
'require uci';
|
||||
'require view';
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require modemmanager_helper as helper';
|
||||
|
||||
/*
|
||||
Written by Konstantine Shevlakov <shevlakov@132lan.ru> 2024
|
||||
*/
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return helper.getModems().then(function (modems) {
|
||||
return Promise.all(modems.filter(function (modem){
|
||||
return modem != null;
|
||||
}).map(function (modem) {
|
||||
return helper.getModemSims(modem.modem).then(function (sims) {
|
||||
modem.sims = sims.filter(function (sim) {
|
||||
return sim != null;
|
||||
});
|
||||
|
||||
return helper.getModemLocation(modem.modem).then(function (location) {
|
||||
modem.location = location;
|
||||
return modem;
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
render: function(modems) {
|
||||
var m, s, o;
|
||||
|
||||
m = new form.Map('mmconfig', _('MMConfig'), _('Manipulate modem bands via mmcli utility'));
|
||||
s = m.section(form.TypedSection, 'modem', null);
|
||||
s.anonymous = true;
|
||||
i=0;
|
||||
modems.reverse().forEach(L.bind(function (modem) {
|
||||
var generic = modem.modem.generic;
|
||||
var modem3gpp = modem.modem['3gpp'];
|
||||
o = s.option(form.Value, 'device'+i, generic.manufacturer + ' ' + generic.model);
|
||||
o.value(generic.device, generic.device);
|
||||
o.default = generic.device;
|
||||
o.readonly = true;
|
||||
o.rmempty = true;
|
||||
o = s.option(form.ListValue, 'network'+i, _('Network Mode'), _('Current')+ ': '+ generic['current-modes']);
|
||||
var modes= generic['supported-modes'];
|
||||
for (var m = 0; m < modes.length; m++){
|
||||
o.value(modes[m],modes[m]);
|
||||
};
|
||||
o.rmempty = true;
|
||||
var bands= generic['supported-bands'];
|
||||
if ( bands.length > 0){
|
||||
o = s.option(form.MultiValue, 'bands'+i, _('Network Bands'), _('List supported bands.<br />If deselect all bands, then used default band modem config.'));
|
||||
for (var b = 0; b < bands.length; b++){
|
||||
o.value(bands[b],bands[b]);
|
||||
};
|
||||
}
|
||||
o.rmempty = true;
|
||||
i++;
|
||||
}, this));
|
||||
s.anonymous = true;
|
||||
return m.render();
|
||||
}
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
local nixio = require "nixio"
|
||||
|
||||
module("luci.controller.modemconfig", package.seeall)
|
||||
|
||||
local utl = require "luci.util"
|
||||
|
||||
function index()
|
||||
entry({"admin", "modem"}, firstchild(), translate("Modem"), 45).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "modemconfig"}, cbi("modem/modemconfig"), translate("Band config"), 9).acl_depends={"unauthenticated"}
|
||||
end
|
||||
|
@ -1,150 +0,0 @@
|
||||
-- Copyright 2021 Konstantine Shevlakov <shevlakov@132lan.ru>
|
||||
-- Licensed to the public under the General Public License 3.0.
|
||||
|
||||
require("nixio.fs")
|
||||
local uci = require "luci.model.uci"
|
||||
|
||||
local m
|
||||
local s
|
||||
local mode2g = os.execute("/usr/share/modeminfo/scripts/getmode.sh 2g")
|
||||
local mode3g = os.execute("/usr/share/modeminfo/scripts/getmode.sh 3g")
|
||||
local mode4g = os.execute("/usr/share/modeminfo/scripts/getmode.sh 4g")
|
||||
local slot = uci.cursor():get_first("modemconfig", "modem", "device")
|
||||
|
||||
if slot == nil then
|
||||
slot = 0
|
||||
end
|
||||
|
||||
|
||||
local b2g = {}
|
||||
|
||||
local t = io.popen("mmcli -J -m "..slot.." | jsonfilter -e '@[\"modem\"][\"generic\"][\"supported-bands\"][*]' | grep -v utran", "r")
|
||||
|
||||
for bands in t:lines() do
|
||||
table.insert(b2g, b2)
|
||||
b2g[#b2g + 1] = bands
|
||||
end
|
||||
|
||||
|
||||
local b3g = {}
|
||||
|
||||
local f = io.popen("mmcli -J -m "..slot.." | jsonfilter -e '@[\"modem\"][\"generic\"][\"supported-bands\"][*]'|awk '/^utran/{print $1}'", "r")
|
||||
|
||||
for bands in f:lines() do
|
||||
table.insert(b3g, b3)
|
||||
b3g[#b3g + 1] = bands
|
||||
end
|
||||
|
||||
|
||||
local b4g = {}
|
||||
|
||||
local p = io.popen("mmcli -J -m "..slot.." | jsonfilter -e '@[\"modem\"][\"generic\"][\"supported-bands\"][*]'|awk '/^eutran/{print $1}'", "r")
|
||||
|
||||
for bands in p:lines() do
|
||||
table.insert(b4g, b4)
|
||||
b4g[#b4g + 1] = bands
|
||||
end
|
||||
|
||||
|
||||
local mm = {}
|
||||
local t = io.popen("mmcli -J -L | jsonfilter -e '@[\"modem-list\"][*]'", "r")
|
||||
|
||||
|
||||
m = Map("modemconfig", translate("Configure modem bands"),
|
||||
translate("Configuration 2G/3G/4G modem frequency bands."))
|
||||
|
||||
s = m:section(TypedSection, "modem", "<p> </p>" .. translate("Choose bands cellular modem"))
|
||||
s.anonymous = true
|
||||
|
||||
dev = s:option(ListValue, "device", translate("Modem"), translate("Select modem"))
|
||||
if mm ~= nil then
|
||||
for dev in t:lines() do
|
||||
table.insert(mm, m)
|
||||
mm[#mm + 1] = dev
|
||||
end
|
||||
for b,g in ipairs(mm) do
|
||||
mm[b] = g
|
||||
if type(g) ~= "table" then
|
||||
n = io.popen("mmcli -J -m "..g.." | jsonfilter -e '@[\"modem\"].*[\"model\"]'", "r")
|
||||
local model = n:read("*l")
|
||||
n:close()
|
||||
x = io.popen("mmcli -J -m "..g.." | jsonfilter -e '@[\"modem\"].*[\"device\"]'", "r")
|
||||
local bus = x:read("*l")
|
||||
x:close()
|
||||
dev:value(bus,model)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--s = m:section(TypedSection, "modem", "<p> </p>" .. translate("Choose bands cellular modem"))
|
||||
--s.anonymous = true
|
||||
|
||||
-- disable if broken
|
||||
|
||||
netmode = s:option(ListValue, "mode", translate("Net Mode"),
|
||||
translate("Preffered Network mode select."))
|
||||
if mode4g == 0 then
|
||||
netmode:value("4g", "4G only")
|
||||
end
|
||||
if mode4g == 0 and mode3g == 0 then
|
||||
netmode:value("p4g3g", "4G/3G: preffer 4G")
|
||||
netmode:value("4gp3g", "4G/3G: preffer 3G")
|
||||
end
|
||||
if mode2g == 0 and mode3g == 0 and mode4g == 0 then
|
||||
netmode:value("p4g3g2g", "4G/3G/2G: preffer 4G")
|
||||
netmode:value("4gp3g2g", "4G/3G/2G: preffer 3G")
|
||||
netmode:value("4g3gp2g", "4G/3G/2G: preffer 2G")
|
||||
end
|
||||
if mode3g == 0 then
|
||||
netmode:value("3g", "3G only")
|
||||
end
|
||||
if mode3g == 0 and mode2g == 0 then
|
||||
netmode:value("p3g2g", "3G/2G: preffer 3G")
|
||||
netmode:value("3gp2g", "3G/2G: preffer 2G")
|
||||
end
|
||||
if mode2g == 0 then
|
||||
netmode:value("2g", "2G only")
|
||||
end
|
||||
netmode.default = "p4g3g"
|
||||
|
||||
|
||||
if mode2g == 0 then
|
||||
gsm = s:option(DynamicList, "gsm_band", translate("2G"))
|
||||
if b2g ~= nil then
|
||||
for b,g in ipairs(b2g) do
|
||||
b2g[b] = g
|
||||
gsm:value(g,g)
|
||||
end
|
||||
end
|
||||
gsm.rmempty = true
|
||||
end
|
||||
|
||||
if mode3g == 0 then
|
||||
wcdma = s:option(DynamicList, "3g_band", translate("3G"))
|
||||
if b3g ~= nil then
|
||||
for b,g in ipairs(b3g) do
|
||||
b3g[b] = g
|
||||
wcdma:value(g,g)
|
||||
end
|
||||
end
|
||||
s.rmempty = true
|
||||
end
|
||||
|
||||
if mode4g == 0 then
|
||||
lte = s:option(DynamicList, "lte_band", translate("4G"), translate("Maybe must reconnect cellular interface. <br /> If deselect all bands, then used default band modem config."))
|
||||
if b4g ~= nil then
|
||||
for b,g in ipairs(b4g) do
|
||||
b4g[b] = g
|
||||
lte:value(g,g)
|
||||
end
|
||||
end
|
||||
s.rmempty = true
|
||||
end
|
||||
|
||||
function m.on_after_commit(Map)
|
||||
luci.sys.call("/usr/bin/modemconfig")
|
||||
end
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s.rmempty = true
|
||||
return m
|
@ -5,39 +5,21 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Konstantine Shevlakov <shevlakov@132lan.ru>\n"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/controller/modemconfig.lua:8
|
||||
msgid "Modem"
|
||||
msgstr "Модем"
|
||||
msgid "Bands"
|
||||
msgstr "Диапазоны"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/controller/modemconfig.lua:9
|
||||
msgid "Band config"
|
||||
msgstr "Настройка диапазонов"
|
||||
msgid "Manipulate modem bands via mmcli utility"
|
||||
msgstr "Управление диапазонами модема через утилиту mmcli"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:12
|
||||
msgid "Configure modem bands"
|
||||
msgstr "Конфигурация диапазонов модема"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:13
|
||||
msgid "Configuration 2G/3G/4G modem frequency bands."
|
||||
msgstr "Конфигурация 2G/3G/4G частот модема."
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:13
|
||||
msgid "Choose bands cellular modem"
|
||||
msgstr "Выбор частот сотовой сети"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:19
|
||||
msgid "Net Mode"
|
||||
msgid "Network Mode"
|
||||
msgstr "Режим сети"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:19
|
||||
msgid "Preffered Network mode select."
|
||||
msgstr "Выбор предпочтительного режима сети."
|
||||
msgid "Network Bands"
|
||||
msgstr "Диапазоны сети"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:61
|
||||
msgid "Select modem"
|
||||
msgstr "Выбор модема"
|
||||
msgid "Current"
|
||||
msgstr "Текуший"
|
||||
|
||||
#: applications/luci-app-mmconfig/luasrc/model/cbi/modem/modemconfig.lua:72
|
||||
msgid "Maybe must reconnect cellular interface. <br /> If deselect all bands, then used default band modem config."
|
||||
msgstr "Возможно потребуется перезапустить сотовое соединение. <br /> Если не выбрано ни одного диапазона, используется конфигурация модема по умолчанию."
|
||||
msgid "List supported bands.<br />If deselect all bands, then used default band modem config."
|
||||
msgstr "Список поддерживаемых диапазонов.<br />Если не выбрано ни одного диапазона, используется конфигурация модема по умолчанию."
|
||||
|
||||
|
3
luci-app-mmconfig/root/etc/config/mmconfig
Normal file
3
luci-app-mmconfig/root/etc/config/mmconfig
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
config modem
|
||||
|
16
luci-app-mmconfig/root/etc/init.d/mmconfig
Executable file
16
luci-app-mmconfig/root/etc/init.d/mmconfig
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
start_service(){
|
||||
logger -t "MMconfig" "MMConfig started"
|
||||
}
|
||||
|
||||
reload_service(){
|
||||
/usr/share/modeminfo/mmconfig
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger mmconfig
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
if [ "$PKG_UPGRADE" != "1" ]; then
|
||||
touch /etc/config/modemconfig
|
||||
uci set modemconfig.@modem[0]=modem
|
||||
fi
|
||||
|
@ -1,29 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
run_config(){
|
||||
# get cellular wwan iface name
|
||||
SECTIONS=$(uci show modemconfig | awk -F [\]\[\@=] '/=modem/{print $3}')
|
||||
# get device path
|
||||
DEV=$(uci show network | awk -F [=] '/device/{gsub("'\''",""); print $2}')
|
||||
for n in $SECTIONS; do
|
||||
SLOT=$(uci -q get modemconfig.@modem[$n].device)
|
||||
NETMODE=$(uci -q get modemconfig.@modem[$n].mode)
|
||||
GET_GSM=$(uci -q get modemconfig.@modem[$n].gsm_band)
|
||||
GET_3G=$(uci -q get modemconfig.@modem[$n].3g_band)
|
||||
GET_LTE=$(uci -q get modemconfig.@modem[$n].lte_band)
|
||||
export SLOT NETMODE GET_GSM GET_3G GET_LTE
|
||||
for d in $DEV; do
|
||||
if [ $SLOT = $d ]; then
|
||||
WWIFACE=$(uci -q show network | grep $d | awk -F [=.] '{print $2}')
|
||||
fi
|
||||
done
|
||||
|
||||
/usr/share/modeminfo/scripts/modemconfig && \
|
||||
sleep 1 && ifdown $WWIFACE && \
|
||||
sleep 1 && ifup $WWIFACE &
|
||||
done
|
||||
}
|
||||
|
||||
sleep 10 && run_config &
|
||||
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"admin/modem/main": {
|
||||
"title": "Modeminfo",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "alias",
|
||||
"path": "admin/modem/main/main"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-mmconfig" ],
|
||||
"uci": { "mmconfig": true }
|
||||
}
|
||||
},
|
||||
|
||||
"admin/modem/main/bands": {
|
||||
"title": "Bands",
|
||||
"order": 63,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "modem/bands"
|
||||
}
|
||||
}
|
||||
}
|
32
luci-app-mmconfig/root/usr/share/modeminfo/mmconfig
Executable file
32
luci-app-mmconfig/root/usr/share/modeminfo/mmconfig
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) Konstantine Shevlakov <shevlakov@132lan.ru> 2024
|
||||
|
||||
get_vars(){
|
||||
dev=$(uci get mmconfig.@modem[0].device${m})
|
||||
net=$(uci get mmconfig.@modem[0].network${m} | awk -F [\;] '{gsub("allowed:\ |preferred:\ ","");gsub("\, ","\|");print $1}' | tr -d ' ')
|
||||
netpref=$(uci get mmconfig.@modem[0].network${m} | awk -F [\;] '{gsub("allowed:\ |preferred:\ ","");gsub("\, ","\|");print $2}' |tr -d ' ')
|
||||
bands=$(uci get mmconfig.@modem[0].bands${m} | awk '{gsub(" ","\|");print $0}')
|
||||
}
|
||||
|
||||
for m in $(seq 0 5); do
|
||||
get_vars >/dev/null 2&>1
|
||||
if [ ${dev} ]; then
|
||||
if ! [ $bands ]; then
|
||||
bands=$(echo $(mmcli -J -m $dev | jsonfilter -e '@["modem"]["generic"]["supported-bands"].*') | awk '{gsub("\ ","\|"); print $0}')
|
||||
fi
|
||||
if [ $bands ]; then
|
||||
mmcli -m $dev --set-allowed-modes="$net" --set-preferred-mode="$netpref"
|
||||
mmcli -m $dev --set-current-bands="$bands"
|
||||
else
|
||||
mmcli -m $dev --set-allowed-modes="$net" --set-preferred-mode="$netpref"
|
||||
fi
|
||||
WWANIF="$WWANIF $(uci show network | grep "$dev" |awk -F [.] '{print $2}')"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for wwan in $WWANIF; do
|
||||
ifup $wwan
|
||||
done
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $1 in
|
||||
2g|3g|4g)
|
||||
SLOT=$(uci -q get modemconfig.@modem[-1].device)
|
||||
if [ $SLOT ]; then
|
||||
mmcli -J -m ${SLOT} | jsonfilter -e '@["modem"]["generic"]["supported-modes"][*]' | grep $1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@ -1,125 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#NETMODE=$(uci -q get modemconfig.@modem[0].mode)
|
||||
#GET_GSM=$(uci -q get modemconfig.@modem[0].gsm_band)
|
||||
#GET_3G=$(uci -q get modemconfig.@modem[0].3g_band)
|
||||
#GET_LTE=$(uci -q get modemconfig.@modem[0].lte_band)
|
||||
#SLOT=$(/usr/bin/mmcli -L | awk '{print $1}' | awk -F [\/] '{print $NF}' | head -1)
|
||||
|
||||
BAND2G=""
|
||||
BAND3G=""
|
||||
BAND4G=""
|
||||
|
||||
# Control empty bands
|
||||
get_bands(){
|
||||
if [ "$GET_BAND" ]; then
|
||||
continue
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Network Mode prefs
|
||||
set_mode(){
|
||||
case $NETMODE in
|
||||
2g)
|
||||
NMODE=2g
|
||||
PREFMODE=none
|
||||
;;
|
||||
3g)
|
||||
NMODE=3g
|
||||
PREFMODE=none
|
||||
;;
|
||||
4g)
|
||||
NMODE=4g
|
||||
PREFMODE=none
|
||||
;;
|
||||
3gp2g)
|
||||
NMODE="2g|3g"
|
||||
PREFMODE=2g
|
||||
;;
|
||||
p3g2g)
|
||||
NMODE="2g|3g"
|
||||
PREFMODE=3g
|
||||
;;
|
||||
p4g3g2g)
|
||||
NMODE="2g|3g|4g"
|
||||
PREFMODE="4g"
|
||||
;;
|
||||
4gp3g2g)
|
||||
NMODE="2g|3g|4g"
|
||||
PREFMODE=3g
|
||||
;;
|
||||
4g3gp2g)
|
||||
NMODE="2g|3g|4g"
|
||||
PREFMODE=2g
|
||||
;;
|
||||
p4g3g)
|
||||
NMODE="4g|3g"
|
||||
PREFMODE="4g"
|
||||
;;
|
||||
4gp3g)
|
||||
NMODE="4g|3g"
|
||||
PREFMODE="3g"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Select 2G bands
|
||||
set_2g(){
|
||||
GET_BAND="$GET_GSM"
|
||||
get_bands
|
||||
for g in $GET_BAND; do
|
||||
BAND2G="$g|$BAND2G"
|
||||
done
|
||||
}
|
||||
|
||||
# Select 3G bands
|
||||
set_3g(){
|
||||
GET_BAND="$GET_3G"
|
||||
get_bands
|
||||
for g in $GET_BAND; do
|
||||
BAND3G="$g|$BAND3G"
|
||||
done
|
||||
}
|
||||
|
||||
# Select 4G bands
|
||||
set_4g(){
|
||||
GET_BAND="$GET_LTE"
|
||||
get_bands
|
||||
for g in $GET_BAND; do
|
||||
BAND4G="$g|$BAND4G"
|
||||
done
|
||||
}
|
||||
# Reset to defautls bands
|
||||
reset_to_defaults(){
|
||||
DEFBAND=""
|
||||
SUPPORTED_BANDS="$(echo $(mmcli -J -m $SLOT | jsonfilter -e '@["modem"]["generic"]["supported-bands"][*]'))"
|
||||
for g in $SUPPORTED_BANDS; do
|
||||
DEFBAND="$g|$DEFBAND"
|
||||
done
|
||||
DEFBAND=$(echo $DEFBAND | sed 's/.$//')
|
||||
}
|
||||
|
||||
set_2g
|
||||
set_3g
|
||||
set_4g
|
||||
|
||||
BAND=$(echo ${BAND2G}${BAND3G}${BAND4G} | sed 's/.$//')
|
||||
# Select band
|
||||
if [ "$BAND" ]; then
|
||||
/usr/bin/mmcli -m $SLOT --set-current-bands="$BAND"
|
||||
else
|
||||
reset_to_defaults
|
||||
/usr/bin/mmcli -m $SLOT --set-current-bands="$DEFBAND"
|
||||
fi
|
||||
|
||||
# Select netmode
|
||||
if [ "$NETMODE" ]; then
|
||||
set_mode
|
||||
/usr/bin/mmcli -m $SLOT --set-allowed-modes="$NMODE" --set-preferred-mode=$PREFMODE
|
||||
else
|
||||
/usr/bin/mmcli -m $SLOT --set-allowed-modes="4g|3g" --set-preferred-mode=4g
|
||||
fi
|
||||
|
@ -1,11 +1,24 @@
|
||||
{
|
||||
"luci-app-mmconfig": {
|
||||
"description": "Grant UCI access for luci-app-mmconfig",
|
||||
"description": "Grant access to mmconfig configuration",
|
||||
"read": {
|
||||
"uci": [ "modemconfig" ]
|
||||
"file": {
|
||||
"/etc/init.d/mmconfig": [ "exec" ]
|
||||
},
|
||||
"cgi-io": [ "exec" ],
|
||||
"ubus": {
|
||||
"file": [ "exec" ],
|
||||
"uci": [ "changes", "get" ]
|
||||
},
|
||||
"uci": [ "mmconfig" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "modemconfig" ]
|
||||
"cgi-io": [ "exec" ],
|
||||
"ubus": {
|
||||
"file": [ "exec" ],
|
||||
"uci": [ "add", "apply", "confirm", "delete", "order", "rename", "set" ]
|
||||
},
|
||||
"uci": [ "mmconfig" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
165
transmission/Makefile
Normal file
165
transmission/Makefile
Normal file
@ -0,0 +1,165 @@
|
||||
#
|
||||
# Copyright (C) 2009-2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=transmission
|
||||
PKG_VERSION:=4.0.5
|
||||
PKG_RELEASE:=7
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://github.com/transmission/transmission/releases/download/$(PKG_VERSION)/
|
||||
PKG_HASH:=skip
|
||||
|
||||
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_CPE_ID:=cpe:/a:transmissionbt:transmission
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_DEPENDS:=libb64 node/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_BUILD_FLAGS:=gc-sections lto
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_LIBCURL_GNUTLS \
|
||||
CONFIG_LIBCURL_MBEDTLS \
|
||||
CONFIG_LIBCURL_OPENSSL \
|
||||
CONFIG_LIBCURL_WOLFSSL \
|
||||
CONFIG_LIBCURL_NOSSL
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
include $(INCLUDE_DIR)/package-seccomp.mk
|
||||
include $(INCLUDE_DIR)/nls.mk
|
||||
|
||||
define Package/transmission/template
|
||||
SUBMENU:=BitTorrent
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=BitTorrent client
|
||||
URL:=https://www.transmissionbt.com
|
||||
DEPENDS:=+libatomic +libcurl +libdeflate +libdht +libevent2 \
|
||||
+libevent2-pthreads +libminiupnpc +libnatpmp +libpthread +libpsl \
|
||||
+librt +libutp +zlib +LIBCURL_NOSSL:libmbedtls \
|
||||
+LIBCURL_GNUTLS:libmbedtls +LIBCURL_MBEDTLS:libmbedtls
|
||||
endef
|
||||
|
||||
define Package/transmission-daemon
|
||||
$(call Package/transmission/template)
|
||||
USERID:=transmission=224:transmission=224
|
||||
endef
|
||||
|
||||
define Package/transmission-cli
|
||||
$(call Package/transmission/template)
|
||||
TITLE+= (utilities)
|
||||
endef
|
||||
|
||||
define Package/transmission-remote
|
||||
$(call Package/transmission/template)
|
||||
TITLE+= (remote)
|
||||
endef
|
||||
|
||||
define Package/transmission-web
|
||||
$(call Package/transmission/template)
|
||||
TITLE+= (webinterface)
|
||||
DEPENDS:=+transmission-daemon
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/transmission-daemon/description
|
||||
Transmission is a simple BitTorrent client.
|
||||
It features a very simple, intuitive interface
|
||||
on top on an efficient, cross-platform back-end.
|
||||
This package contains the daemon itself.
|
||||
endef
|
||||
|
||||
define Package/transmission-cli/description
|
||||
CLI utilities for transmission.
|
||||
endef
|
||||
|
||||
define Package/transmission-remote/description
|
||||
CLI remote interface for transmission.
|
||||
endef
|
||||
|
||||
define Package/transmission-web/description
|
||||
Webinterface resources for transmission.
|
||||
endef
|
||||
|
||||
define Package/transmission-daemon/conffiles
|
||||
/etc/config/transmission
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += -DHAVE_SIZE_T -latomic
|
||||
TARGET_LDFLAGS += -Wl,--as-needed
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DENABLE_CLI:BOOL=YES \
|
||||
-DENABLE_GTK:BOOL=NO \
|
||||
-DENABLE_QT:BOOL=NO \
|
||||
-DENABLE_MAC:BOOL=NO \
|
||||
-DENABLE_TESTS:BOOL=NO \
|
||||
-DENABLE_NLS:BOOL=NO \
|
||||
-DENABLE_UTP:BOOL=YES \
|
||||
-DRUN_CLANG_TIDY:BOOL=NO \
|
||||
-DUSE_SYSTEM_EVENT2:BOOL=YES \
|
||||
-DUSE_SYSTEM_DEFLATE:BOOL=YES \
|
||||
-DUSE_SYSTEM_DHT:BOOL=YES \
|
||||
-DUSE_SYSTEM_MINIUPNPC:BOOL=YES \
|
||||
-DUSE_SYSTEM_NATPMP:BOOL=YES \
|
||||
-DUSE_SYSTEM_UTP:BOOL=YES \
|
||||
-DUSE_SYSTEM_B64:BOOL=YES \
|
||||
-DUSE_SYSTEM_PSL:BOOL=YES \
|
||||
-DWITH_INOTIFY:BOOL=YES \
|
||||
-DWITH_KQUEUE:BOOL=NO \
|
||||
-DWITH_SYSTEMD:BOOL=NO \
|
||||
-DB64_INCLUDE_DIR=$(STAGING_DIR)/usr/include \
|
||||
-DB64_LIBRARY=$(STAGING_DIR)/usr/lib/libb64.a \
|
||||
-DDHT_INCLUDE_DIR=$(STAGING_DIR)/usr/include \
|
||||
-DDHT_LIBRARY=$(STAGING_DIR)/usr/lib/libdht.so \
|
||||
-DUTP_INCLUDE_DIR=$(STAGING_DIR)/usr/include \
|
||||
-DUTP_LIBRARY=$(STAGING_DIR)/usr/lib/libutp.so \
|
||||
$(if $(CONFIG_LIBCURL_NOSSL),-DWITH_CRYPTO=mbedtls) \
|
||||
$(if $(CONFIG_LIBCURL_GNUTLS),-DWITH_CRYPTO=mbedtls) \
|
||||
$(if $(CONFIG_LIBCURL_MBEDTLS),-DWITH_CRYPTO=mbedtls) \
|
||||
$(if $(CONFIG_LIBCURL_OPENSSL),-DWITH_CRYPTO=openssl) \
|
||||
$(if $(CONFIG_LIBCURL_WOLFSSL),-DWITH_CRYPTO=wolfssl)
|
||||
|
||||
define Package/transmission-daemon/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/transmission-daemon $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) files/transmission.init $(1)/etc/init.d/transmission
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) files/transmission.config $(1)/etc/config/transmission
|
||||
$(INSTALL_DIR) $(1)/etc/sysctl.d/
|
||||
$(INSTALL_CONF) files/transmission.sysctl $(1)/etc/sysctl.d/20-transmission.conf
|
||||
$(call InstallSeccomp,$(1),./files/transmission-daemon.json)
|
||||
endef
|
||||
|
||||
define Package/transmission-cli/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/transmission-cli \
|
||||
$(PKG_INSTALL_DIR)/usr/bin/transmission-create \
|
||||
$(PKG_INSTALL_DIR)/usr/bin/transmission-edit \
|
||||
$(PKG_INSTALL_DIR)/usr/bin/transmission-show \
|
||||
$(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/transmission-remote/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/transmission-remote $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/transmission-web/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/transmission
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/share/transmission/public_html $(1)/usr/share/transmission/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,transmission-daemon))
|
||||
$(eval $(call BuildPackage,transmission-cli))
|
||||
$(eval $(call BuildPackage,transmission-remote))
|
||||
$(eval $(call BuildPackage,transmission-web))
|
114
transmission/files/transmission-daemon.json
Normal file
114
transmission/files/transmission-daemon.json
Normal file
@ -0,0 +1,114 @@
|
||||
{
|
||||
"defaultAction": "SCMP_ACT_KILL_PROCESS",
|
||||
"syscalls": [
|
||||
{
|
||||
"names": [
|
||||
"accept",
|
||||
"accept4",
|
||||
"access",
|
||||
"arm_fadvise64_64",
|
||||
"bind",
|
||||
"brk",
|
||||
"clock_gettime",
|
||||
"clock_gettime64",
|
||||
"clone",
|
||||
"close",
|
||||
"connect",
|
||||
"copy_file_range",
|
||||
"epoll_create1",
|
||||
"epoll_ctl",
|
||||
"epoll_pwait",
|
||||
"eventfd2",
|
||||
"exit",
|
||||
"exit_group",
|
||||
"faccessat",
|
||||
"fadvise64",
|
||||
"fadvise64_64",
|
||||
"fallocate",
|
||||
"fchmod",
|
||||
"fcntl",
|
||||
"fcntl64",
|
||||
"ftruncate",
|
||||
"ftruncate64",
|
||||
"fstat",
|
||||
"fstat64",
|
||||
"fsync",
|
||||
"futex",
|
||||
"getdents64",
|
||||
"getegid32",
|
||||
"getenv",
|
||||
"geteuid32",
|
||||
"getgid32",
|
||||
"getpeername",
|
||||
"getpid",
|
||||
"getrandom",
|
||||
"getsockname",
|
||||
"getsockopt",
|
||||
"getuid",
|
||||
"getuid32",
|
||||
"inotify_add_watch",
|
||||
"inotify_init1",
|
||||
"inotify_rm_watch",
|
||||
"ioctl",
|
||||
"listen",
|
||||
"_llseek",
|
||||
"lseek",
|
||||
"madvise",
|
||||
"membarrier",
|
||||
"mkdir",
|
||||
"mkdirat",
|
||||
"mmap",
|
||||
"mmap2",
|
||||
"mprotect",
|
||||
"mremap",
|
||||
"munmap",
|
||||
"nanosleep",
|
||||
"newfstatat",
|
||||
"_newselect",
|
||||
"open",
|
||||
"openat",
|
||||
"pipe",
|
||||
"pipe2",
|
||||
"poll",
|
||||
"ppoll",
|
||||
"pread64",
|
||||
"prlimit64",
|
||||
"pselect6",
|
||||
"pwrite64",
|
||||
"quotactl",
|
||||
"read",
|
||||
"readlink",
|
||||
"readlinkat",
|
||||
"readv",
|
||||
"recvfrom",
|
||||
"recvmsg",
|
||||
"rename",
|
||||
"renameat",
|
||||
"rmdir",
|
||||
"rt_sigaction",
|
||||
"rt_sigprocmask",
|
||||
"rt_sigreturn",
|
||||
"select",
|
||||
"sendto",
|
||||
"setsockopt",
|
||||
"shutdown",
|
||||
"signalfd4",
|
||||
"sigreturn",
|
||||
"socket",
|
||||
"socketpair",
|
||||
"stat",
|
||||
"stat64",
|
||||
"statfs",
|
||||
"statfs64",
|
||||
"statx",
|
||||
"umask",
|
||||
"uname",
|
||||
"unlink",
|
||||
"unlinkat",
|
||||
"write",
|
||||
"writev"
|
||||
],
|
||||
"action": "SCMP_ACT_ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
78
transmission/files/transmission.config
Normal file
78
transmission/files/transmission.config
Normal file
@ -0,0 +1,78 @@
|
||||
config transmission
|
||||
option enabled 0
|
||||
option config_dir '/tmp/transmission'
|
||||
option config_overwrite '1'
|
||||
option user 'transmission'
|
||||
option group 'transmission'
|
||||
option mem_percentage 50
|
||||
option nice 10
|
||||
option web_home ''
|
||||
option alt_speed_down 50
|
||||
option alt_speed_enabled false
|
||||
option alt_speed_time_begin 540
|
||||
option alt_speed_time_day 127
|
||||
option alt_speed_time_enabled false
|
||||
option alt_speed_time_end 1020
|
||||
option alt_speed_up 50
|
||||
option bind_address_ipv4 '0.0.0.0'
|
||||
option bind_address_ipv6 '::'
|
||||
option blocklist_enabled false
|
||||
option blocklist_url ''
|
||||
option cache_size_mb 2
|
||||
option dht_enabled true
|
||||
option download_dir '/tmp/transmission/done'
|
||||
option download_queue_enabled true
|
||||
option download_queue_size 4
|
||||
option encryption 1
|
||||
option idle_seeding_limit 30
|
||||
option idle_seeding_limit_enabled false
|
||||
option incomplete_dir '/tmp/transmission/incomplete'
|
||||
option incomplete_dir_enabled false
|
||||
option lazy_bitfield_enabled true
|
||||
option lpd_enabled false
|
||||
option message_level 1
|
||||
option peer_congestion_algorithm ''
|
||||
option peer_limit_global 240
|
||||
option peer_limit_per_torrent 60
|
||||
option peer_port 51413
|
||||
option peer_port_random_high 65535
|
||||
option peer_port_random_low 49152
|
||||
option peer_port_random_on_start false
|
||||
option peer_socket_tos 'default'
|
||||
option pex_enabled true
|
||||
option port_forwarding_enabled true
|
||||
option preallocation 1
|
||||
option prefetch_enabled true
|
||||
option queue_stalled_enabled true
|
||||
option queue_stalled_minutes 30
|
||||
option ratio_limit 2.0000
|
||||
option ratio_limit_enabled false
|
||||
option rename_partial_files true
|
||||
option rpc_authentication_required false
|
||||
option rpc_bind_address '0.0.0.0'
|
||||
option rpc_enabled true
|
||||
option rpc_host_whitelist '127.0.0.1,192.168.1.*'
|
||||
option rpc_host_whitelist_enabled false
|
||||
option rpc_password ''
|
||||
option rpc_port 9091
|
||||
option rpc_url '/transmission/'
|
||||
option rpc_username ''
|
||||
option rpc_whitelist '127.0.0.1,192.168.1.*'
|
||||
option rpc_whitelist_enabled false
|
||||
option scrape_paused_torrents_enabled true
|
||||
option script_torrent_done_enabled false
|
||||
option script_torrent_done_filename ''
|
||||
option seed_queue_enabled false
|
||||
option seed_queue_size 10
|
||||
option speed_limit_down 100
|
||||
option speed_limit_down_enabled false
|
||||
option speed_limit_up 20
|
||||
option speed_limit_up_enabled false
|
||||
option start_added_torrents true
|
||||
option trash_original_torrent_files false
|
||||
option umask 18
|
||||
option upload_slots_per_torrent 14
|
||||
option utp_enabled true
|
||||
option scrape_paused_torrents true
|
||||
option watch_dir_enabled false
|
||||
option watch_dir ''
|
216
transmission/files/transmission.init
Normal file
216
transmission/files/transmission.init
Normal file
@ -0,0 +1,216 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2010-2015 OpenWrt.org
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
PROG="/usr/bin/transmission-daemon"
|
||||
|
||||
LIST_SEP="
|
||||
"
|
||||
|
||||
append_params() {
|
||||
local p; local v; local s="$1"; shift
|
||||
IFS="$LIST_SEP"
|
||||
for p in "$@"; do
|
||||
config_get v "$s" "$p"
|
||||
for v in $v; do
|
||||
[ -n "$v" ] && echo "\"$p\": $v," | sed -e 's|_|-|g'
|
||||
done
|
||||
done
|
||||
unset IFS
|
||||
}
|
||||
|
||||
append_params_quotes() {
|
||||
local p; local v; local s="$1"; shift
|
||||
IFS="$LIST_SEP"
|
||||
for p in "$@"; do
|
||||
config_get v "$s" "$p"
|
||||
for v in $v; do
|
||||
[ -n "$v" ] && {
|
||||
printf "\"%s" "$p" | sed -e 's|/|\\/|g;s|_|-|g'; \
|
||||
echo "\": \"$v\","
|
||||
}
|
||||
done
|
||||
done
|
||||
unset IFS
|
||||
}
|
||||
|
||||
transmission() {
|
||||
local cfg="$1"
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled "$cfg" enabled 0
|
||||
[ "$enabled" -gt 0 ] || {
|
||||
echo "Transmission not enabled. Please enable in /etc/config/transmission"
|
||||
logger -t "transmission" -p "daemon.info" "Transmission not enabled. Please enable in /etc/config/transmission"
|
||||
return 1
|
||||
}
|
||||
|
||||
local config_dir
|
||||
config_get config_dir "$cfg" 'config_dir' '/var/etc/transmission'
|
||||
local user
|
||||
config_get user "$cfg" 'user'
|
||||
local group
|
||||
config_get group "$cfg" 'group'
|
||||
local download_dir
|
||||
config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission'
|
||||
local incomplete_dir
|
||||
config_get incomplete_dir "$cfg" 'incomplete_dir' '/var/etc/transmission'
|
||||
local incomplete_dir_enabled
|
||||
config_get_bool incomplete_dir_enabled "$cfg" 'incomplete_dir_enabled' 0
|
||||
local watch_dir
|
||||
config_get watch_dir "$cfg" 'watch_dir' '/var/etc/transmission'
|
||||
local watch_dir_enabled
|
||||
config_get_bool watch_dir_enabled "$cfg" 'watch_dir_enabled' 0
|
||||
local mem_percentage
|
||||
config_get mem_percentage "$cfg" 'mem_percentage' '50'
|
||||
local config_overwrite
|
||||
config_get_bool config_overwrite "$cfg" config_overwrite 1
|
||||
local nice
|
||||
config_get nice "$cfg" nice 0
|
||||
local web_home
|
||||
config_get web_home "$cfg" 'web_home'
|
||||
local ca_bundle
|
||||
config_get_bool ca_bundle "$cfg" ca_bundle 1
|
||||
[ "$ca_bundle" -gt 0 ] && ca_bundle_file="/etc/ssl/certs/ca-certificates.crt"
|
||||
local seccomp_path
|
||||
|
||||
local MEM
|
||||
MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo)
|
||||
local USE
|
||||
[ "$MEM" -gt 1 ] && USE=$((MEM * mem_percentage * 10))
|
||||
|
||||
config_file="$config_dir/settings.json"
|
||||
[ -d "$config_dir" ] || {
|
||||
mkdir -p "$config_dir"
|
||||
chmod 0755 "$config_dir"
|
||||
touch "$config_file"
|
||||
mkdir -p "$config_dir/resume"
|
||||
mkdir -p "$config_dir/torrents"
|
||||
mkdir -p "$config_dir/blocklists"
|
||||
[ -e "$config_dir/stats.json" ] || touch "$config_dir/stats.json"
|
||||
[ -z "$user" ] || chown -R "$user:$group" "$config_dir"
|
||||
}
|
||||
|
||||
[ -d "$download_dir" ] || {
|
||||
mkdir -p "$download_dir"
|
||||
chmod 0755 "$download_dir"
|
||||
[ -z "$user" ] || chown -R "$user:$group" "$download_dir"
|
||||
}
|
||||
|
||||
[ "$incomplete_dir_enabled" = "0" ] || [ -d "$incomplete_dir" ] || {
|
||||
mkdir -p "$incomplete_dir"
|
||||
chmod 0755 "$incomplete_dir"
|
||||
[ -z "$user" ] || chown -R "$user:$group" "$incomplete_dir"
|
||||
}
|
||||
|
||||
[ "$config_overwrite" = 0 ] || {
|
||||
|
||||
echo "{"
|
||||
|
||||
append_params "$cfg" \
|
||||
alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \
|
||||
alt_speed_time_enabled alt_speed_time_end alt_speed_up blocklist_enabled \
|
||||
cache_size_mb download_queue_enabled download_queue_size \
|
||||
dht_enabled encryption idle_seeding_limit idle_seeding_limit_enabled \
|
||||
incomplete_dir_enabled lazy_bitfield_enabled lpd_enabled message_level \
|
||||
peer_id_ttl_hours peer_limit_global peer_limit_per_torrent peer_port \
|
||||
peer_port_random_high peer_port_random_low peer_port_random_on_start \
|
||||
pex_enabled port_forwarding_enabled preallocation prefetch_enabled \
|
||||
ratio_limit ratio_limit_enabled rename_partial_files rpc_authentication_required \
|
||||
rpc_enabled rpc_port rpc_whitelist_enabled queue_stalled_enabled \
|
||||
queue_stalled_minutes scrape_paused_torrents_enabled script_torrent_done_enabled \
|
||||
seed_queue_enabled seed_queue_size \
|
||||
speed_limit_down speed_limit_down_enabled speed_limit_up \
|
||||
speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
|
||||
umask upload_slots_per_torrent utp_enabled \
|
||||
watch_dir_enabled rpc_host_whitelist_enabled
|
||||
|
||||
append_params_quotes "$cfg" \
|
||||
blocklist_url bind_address_ipv4 bind_address_ipv6 download_dir incomplete_dir \
|
||||
peer_congestion_algorithm peer_socket_tos rpc_bind_address rpc_password rpc_url \
|
||||
rpc_username rpc_host_whitelist rpc_whitelist script_torrent_done_filename watch_dir
|
||||
|
||||
echo "\"invalid-key\": false"
|
||||
echo "}"
|
||||
|
||||
} > "$config_file"
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -f -g "$config_dir"
|
||||
procd_set_param user "$user"
|
||||
procd_set_param group "$group"
|
||||
procd_set_param nice "$nice"
|
||||
procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
|
||||
seccomp_path="/etc/seccomp/transmission-daemon.json"
|
||||
if [ -f "$seccomp_path" ]; then
|
||||
procd_set_param seccomp "$seccomp_path"
|
||||
fi
|
||||
|
||||
if [ -z "$USE" ]; then
|
||||
procd_set_param limits core="0 0"
|
||||
else
|
||||
procd_set_param limits core="0 0" as="$USE $USE"
|
||||
logger -t transmission "Starting with $USE virt mem"
|
||||
fi
|
||||
|
||||
[ -d "$web_home" ] && procd_append_param env TRANSMISSION_WEB_HOME="$web_home"
|
||||
[ "$ca_bundle" -gt 0 ] && procd_append_param env CURL_CA_BUNDLE="$ca_bundle_file"
|
||||
|
||||
procd_add_jail transmission log
|
||||
procd_add_jail_mount "$config_file"
|
||||
procd_add_jail_mount_rw "$config_dir/resume"
|
||||
procd_add_jail_mount_rw "$config_dir/torrents"
|
||||
procd_add_jail_mount_rw "$config_dir/blocklists"
|
||||
procd_add_jail_mount_rw "$config_dir/stats.json"
|
||||
procd_add_jail_mount_rw "$download_dir"
|
||||
[ "$incomplete_dir_enabled" = "1" ] && procd_add_jail_mount_rw "$incomplete_dir"
|
||||
[ "$watch_dir_enabled" = "1" ] && procd_add_jail_mount_rw "$watch_dir"
|
||||
web_home="${web_home:-/usr/share/transmission/public_html}"
|
||||
[ -d "$web_home" ] && procd_add_jail_mount "$web_home"
|
||||
[ -f "$ca_bundle_file" ] && procd_add_jail_mount "$ca_bundle_file"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load 'transmission'
|
||||
config_foreach transmission 'transmission'
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
procd_send_signal "$PROG"
|
||||
}
|
||||
|
||||
transmission_mount_triggers() {
|
||||
local cfg="$1"
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled "$cfg" enabled 0
|
||||
[ "$enabled" -gt 0 ] || return 0
|
||||
|
||||
local config_dir download_dir incomplete_dir incomplete_dir_enabled \
|
||||
watch_dir watch_dir_enabled web_home service_dirs
|
||||
config_get config_dir "$cfg" 'config_dir' '/var/etc/transmission'
|
||||
config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission'
|
||||
config_get_bool incomplete_dir_enabled "$cfg" 'incomplete_dir_enabled' 0
|
||||
config_get incomplete_dir "$cfg" 'incomplete_dir' '/var/etc/transmission'
|
||||
config_get_bool watch_dir_enabled "$cfg" 'watch_dir_enabled' 0
|
||||
config_get watch_dir "$cfg" 'watch_dir' '/var/etc/transmission'
|
||||
config_get web_home "$cfg" 'web_home'
|
||||
|
||||
service_dirs="$config_dir $download_dir $web_home"
|
||||
[ "$incomplete_dir_enabled" = "0" ] || service_dirs="$service_dirs $incomplete_dir"
|
||||
[ "$watch_dir_enabled" = "0" ] || service_dirs="$service_dirs $watch_dir"
|
||||
|
||||
procd_add_restart_mount_trigger $service_dirs
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger 'transmission'
|
||||
config_load 'transmission'
|
||||
config_foreach transmission_mount_triggers 'transmission'
|
||||
}
|
6
transmission/files/transmission.sysctl
Normal file
6
transmission/files/transmission.sysctl
Normal file
@ -0,0 +1,6 @@
|
||||
# Transmission requests large buffers by default
|
||||
net.core.rmem_max = 4194304
|
||||
net.core.wmem_max = 1048576
|
||||
|
||||
# Some firewalls block SYN packets that are too small
|
||||
net.ipv4.tcp_adv_win_scale = 4
|
Loading…
Reference in New Issue
Block a user