Abstracted the transmission up and down events to seperate scripts

This commit is contained in:
Jeremy Andrews
2018-01-01 13:04:15 +13:00
parent af699006c7
commit 0ba1bc6af7
5 changed files with 50 additions and 35 deletions

42
tinyproxy/start.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
PROXY_CONF='/etc/tinyproxy.conf'
if [ "${WEBPROXY_ENABLED}" = "true" ]; then
echo "STARTING TINYPROXY"
if [ -z "$WEBPROXY_PORT" ] ; then
set_port $WEBPROXY_PORT
else
# Always default back to port 8888
set_port 8888
fi
/etc/init.d/tinyproxy start
echo "Tinyproxy startup script complete."
fi
set_port () {
re='^[0-9]+$'
if ! [[ $1 =~ $re ]] ; then
echo "Port: Not a number" >&2; exit 1
fi
# Port: Specify the port which tinyproxy will listen on. Please note
# that should you choose to run on a port lower than 1024 you will need
# to start tinyproxy using root.
if [ $1 \< 1024 ];
then
echo "tinyproxy: $1 is lower than 1024. Ports below 1024 are not permitted.";
exit 1
fi;
echo "Setting tinyproxy port to $1";
sed -i -e"s,^Port .*,Port $1," $PROXY_CONF
}