set-proxy/set-proxy.sh

44 lines
1.2 KiB
Bash

#!/bin/sh
# source: https://www.ivonet.nl/2019/04/14/set-your-proxy-client-on-synology-nas-through-cli/
PORT=3128
HOST=localhost
ENABLE=true
while getopts ":p:h:ad?" opt; do
case ${opt} in
h) HOST=$OPTARG
;;
p) PORT=$OPTARG
;;
a) ENABLE=true
;;
d) ENABLE=false
;;
\?) echo "Usage: set-proxy [-p PORT_NUMBER] [-h HOSTNAME] [-a] [-d] [-?]"
echo " -p PORT_NUMBER : sets the portnumber (default: 3128)"
echo " -h HOSTNAME : sets the hostname (default: localhost)"
echo " -a : activates the proxy client (=default)"
echo " -d : disables the proxy client"
echo " -? : this help message"
exit 0
;;
esac
done
/usr/syno/bin/synowebapi --exec \
"api"="SYNO.Core.Network.Proxy" \
"method"="set" \
"version"="1" \
"enable"=${ENABLE:-true} \
"http_host"="${HOST}" \
"http_port"="${PORT}" \
"enable_different_host"=false \
"enable_auth"=false \
"enable_bypass"=false \
"https_host"="${HOST}" \
"https_port"="${PORT}"
/usr/syno/bin/synowebapi --exec \
"api"="SYNO.Core.Network.Proxy" \
"method"="get"