op-packages/openwrt-natmapt/files/client/Transmission
github-actions[bot] 32600acc60 🌴 Sync 2026-03-05 23:51:42
2026-03-05 23:51:42 +08:00

28 lines
737 B
Bash

#!/bin/sh
# Copyright (C) 2023 muink https://github.com/muink
#
# Client listen port refresh script
#
# depends
. /usr/lib/natmap/common.sh
start() {
local retry='--connect-timeout 1 --retry 0'
scheme='http' # only supports http
local sid="$($CURL $retry -L \
-u ${username}:${password} \
--url ${scheme}://${host}:${web_port}/transmission/rpc \
| sed 's|.*<code>||g;s|</code>.*||g')"
$CURL $retry -L -X POST \
-H "$sid" -u ${username}:${password} \
-d '{"method":"session-set","arguments":{"peer-port":"'"${port}"'"}}' \
--url ${scheme}://${host}:${web_port}/transmission/rpc
}
# All external parameters required
ALL_PARAMS="host port scheme web_port username password"
eval "$(JSON_EXPORT "$1")"; shift
start "$@"