ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/net/privoxy/files/privoxy.config b/external/subpack/net/privoxy/files/privoxy.config
new file mode 100644
index 0000000..95b6cf1
--- /dev/null
+++ b/external/subpack/net/privoxy/files/privoxy.config
@@ -0,0 +1,44 @@
+# this file support all available configuration options of Privoxy web-proxy
+# the scripts move all options to the final privoxy readable configuration file
+#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!! privoxy uses "-" in option names but uci only support "_" !!!
+# !!! privoxy "listen-address" must be uci "listen_address" !!!
+# !!! !!!
+# !!! if you add entries please use !!!
+# !!! option for options with one parameter (option confdir) !!!
+# !!! list for options with multiple parameters (list listen_address) !!!
+# !!! !!!
+# !!! special handling for debug option !!!
+# !!! privoxy option "debug 1024" must be uci option debug_1024 '1' !!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#
+config privoxy 'privoxy'
+ option confdir '/etc/privoxy'
+ option logdir '/var/log'
+ option logfile 'privoxy.log'
+ list filterfile 'default.filter'
+# list filterfile 'user.filter'
+ list actionsfile 'match-all.action'
+ list actionsfile 'default.action'
+# list actionsfile 'user.action'
+# list listen_address '127.0.0.1:8118'
+ list listen_address '192.168.1.1:8118'
+ option toggle '1'
+ option enable_remote_toggle '1'
+ option enable_remote_http_toggle '0'
+ option enable_edit_actions '1'
+ option enforce_blocks '0'
+ option buffer_limit '4096'
+ option forwarded_connect_retries '0'
+ option accept_intercepted_requests '0'
+ option allow_cgi_request_crunching '0'
+ option split_large_forms '0'
+ option keep_alive_timeout '300'
+ option socket_timeout '300'
+ list permit_access '192.168.1.0/24'
+ option debug_1 '0'
+ option debug_512 '1'
+ option debug_1024 '0'
+ option debug_4096 '1'
+ option debug_8192 '1'
diff --git a/external/subpack/net/privoxy/files/privoxy.hotplug b/external/subpack/net/privoxy/files/privoxy.hotplug
new file mode 100644
index 0000000..2673b20
--- /dev/null
+++ b/external/subpack/net/privoxy/files/privoxy.hotplug
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# only (re-)start on ifup
+[ "$ACTION" = "ifup" ] || exit 0
+# only start if boot_delay is done
+[ -f /tmp/privoxy.hotplug ] || exit 0
+
+PIDFILE=/var/run/privoxy.pid
+
+_PID=$(cat $PIDFILE 2>/dev/null)
+kill -1 $_PID 2>/dev/null
+if [ $? -eq 0 ]; then
+ # only restart if already running
+ logger -p daemon.info -t "privoxy[$_PID]" \
+ "Restart request due to '$ACTION' of interface '$INTERFACE'"
+ /etc/init.d/privoxy restart
+else
+ # only start if enabled
+ /etc/init.d/privoxy enabled && /etc/init.d/privoxy start
+fi
diff --git a/external/subpack/net/privoxy/files/privoxy.init b/external/subpack/net/privoxy/files/privoxy.init
new file mode 100644
index 0000000..ae493c2
--- /dev/null
+++ b/external/subpack/net/privoxy/files/privoxy.init
@@ -0,0 +1,180 @@
+#!/bin/sh /etc/rc.common
+
+START=95
+STOP=10
+
+PIDFILE=/var/run/privoxy.pid
+CFGFILE=/var/etc/privoxy.conf
+CFGTEMP=/var/etc/privoxy.conf.tmp
+
+_uci2conf() {
+ # redefined callback for options when calling config_load
+ config_cb() {
+ if [ ."$2" != ."privoxy" ]; then
+ option_cb() { return 0; }
+ else
+ option_cb()
+ {
+ # $1 name of variable
+ # $2 value
+ local __OPT="$1"
+ local __VAL="$2"
+ case $__OPT in
+ confdir|templdir|temporary_directory|logdir|logfile)
+ # needs to be handled separately because we need to set permissions
+ # AND needs to be defined first because of a BUG inside privoxy
+ # require directories to be defined first inside config
+ ;;
+ debug_*)
+ [ $__VAL -eq 0 ] && return # not set ignore
+ echo -e "debug\t$(echo $__OPT | sed -e 's#debug_##g')" >> $CFGTEMP ;;
+ *)
+ # detect list options (LENGTH) and ignore
+ echo $__OPT | grep -i "_LENGTH" >/dev/null 2>&1 && return
+ # detect list options (ITEM) and ignore
+ echo $__OPT | grep -i "_ITEM" >/dev/null 2>&1 && __OPT=$(echo $__OPT | sed -e "s#_ITEM.*##g")
+ # uci only accept "_" but we need "-"
+ local __OPT=$(echo $__OPT | sed -e "s#_#-#g")
+ # write to config
+ echo -e "$__OPT\t$__VAL" >> $CFGTEMP
+ ;;
+ esac
+ }
+
+ list_cb()
+ {
+ option_cb "$@"
+ }
+ fi
+ }
+
+ # temporary config file
+ # privoxy need read access
+ mkdir -m0755 -p /var/etc
+ echo "" > $CFGTEMP
+ chmod 644 $CFGTEMP
+ chgrp privoxy $CFGTEMP
+
+ echo '### AUTO-GENERATED CONFIGURATION' >> $CFGTEMP
+ echo '### USED BY PRIVOXY' >> $CFGTEMP
+ echo '### DO NOT EDIT' >> $CFGTEMP
+ echo '### SEE /etc/config/privoxy INSTEAD' >> $CFGTEMP
+ echo '' >> $CFGTEMP
+
+ # logdir and logfile
+ # privoxy needs read/write access
+ _LOGDIR=$(uci -q get privoxy.privoxy.logdir) || _LOGDIR="/var/log"
+ _LOGFILE=$(uci -q get privoxy.privoxy.logfile) || _LOGFILE="privoxy.log"
+ mkdir -m0755 -p $_LOGDIR
+ touch $_LOGDIR/$_LOGFILE
+ chmod 664 $_LOGDIR/$_LOGFILE
+ chown privoxy:privoxy $_LOGDIR/$_LOGFILE
+ echo -e "logdir\t$_LOGDIR" >> $CFGTEMP
+ echo -e "logfile\t$_LOGFILE" >> $CFGTEMP
+
+ # confdir
+ # privoxy needs read access (possibly write access)
+ _CONFDIR=$(uci -q get privoxy.privoxy.confdir) || _CONFDIR="/etc/privoxy"
+ chmod 755 $_CONFDIR
+ chmod 664 $_CONFDIR/*
+ chgrp privoxy $_CONFDIR $_CONFDIR/*
+ echo -e "confdir\t$_CONFDIR" >> $CFGTEMP
+
+ # templdir
+ # privoxy need read access
+ _TEMPLDIR=$(uci -q get privoxy.privoxy.templdir) # no default needed
+ if [ -z "$_TEMPLDIR" ]; then
+ chmod 755 $_CONFDIR/templates
+ chmod 644 $_CONFDIR/templates/*
+ chgrp privoxy $_CONFDIR/templates $_CONFDIR/templates/*
+ else
+ chmod 755 $_TEMPLDIR
+ chmod 644 $_TEMPLDIR/*
+ chgrp privoxy $_TEMPLDIR $_TEMPLDIR/*
+ echo -e "templdir\t$_TEMPLDIR" >> $CFGTEMP
+ fi
+
+ # temporary-directory
+ # privoxy needs read/write access
+ _TMP_DIR=$(uci -q get privoxy.privoxy.temporary_directory) # no default needed
+ if [ -n "$_TMP_DIR" ]; then
+ mkdir -m0750 -p $_TMP_DIR
+ chown privoxy:privoxy $_TMP_DIR
+ echo -e "temporary-directory\t$_TMP_DIR" >> $CFGTEMP
+ fi
+
+ config_load "privoxy" # calling above option_cb() and write the rest into $CFGTEMP
+
+ # move temp to final privoxy readable configuration
+ mv -f $CFGTEMP $CFGFILE
+ return 0
+}
+
+boot() {
+ # wait a given time (default 10 seconds) before startup
+ # to wait for interfaces to come up / not using hotplug events during boot
+ _start() {
+ [ $1 -gt 0 ] && {
+ logger -p daemon.info -t "privoxy[]" "Scheduled startup in $1 seconds"
+ sleep $1
+ }
+ start
+ }
+
+ local _DELAY
+ _DELAY=$(uci_get "privoxy" "system" "boot_delay" "10")
+ _start $_DELAY &
+ return 0
+}
+
+shutdown() {
+ rm -f /tmp/privoxy.hotplug
+ stop
+}
+
+start() {
+ # if already running do nothing
+ local _PID=$(cat $PIDFILE 2>/dev/null)
+ kill -1 $_PID 2>/dev/null && return 0
+
+ _uci2conf
+ /usr/sbin/privoxy --pidfile $PIDFILE --user privoxy.privoxy $CFGFILE
+ touch /tmp/privoxy.hotplug
+
+ # verify startup
+ _PID=$(cat $PIDFILE 2>/dev/null)
+ kill -1 $_PID 2>/dev/null
+ local _ERR=$?
+ [ $_ERR -eq 0 ] \
+ && logger -p daemon.notice -t "privoxy[$_PID]" "Started successfully"\
+ || logger -p daemon.warn -t "privoxy[]" "Failed to start"
+ return $_ERR
+}
+
+reload() {
+ # reload is also used by luci-app-privoxy
+ local _PID=$(cat $PIDFILE 2>/dev/null)
+ kill -1 $_PID 2>/dev/null
+ if [ $? -eq 0 ]; then
+ # only restart if already running
+ restart
+ else
+ # only start if enabled
+ enabled && start
+ fi
+ return 0
+}
+
+stop() {
+ local _PID=$(cat $PIDFILE 2>/dev/null)
+ kill -15 $_PID 2>/dev/null
+ sleep 1 # give time to shutdown
+ local _tmp=$(pgrep /usr/sbin/privoxy | tr "\n" " ")
+ if [ -z "$_tmp" ]; then
+ logger -p daemon.notice -t "privoxy[$_PID]" "Shutdown successfully"
+ else
+ kill -9 $_tmp # Normally never come here
+ logger -p daemon.warn -t "privoxy[$_tmp]" "Shutdown forced by KILL"
+ fi
+ return 0
+}
diff --git a/external/subpack/net/privoxy/files/privoxy.upgrade b/external/subpack/net/privoxy/files/privoxy.upgrade
new file mode 100644
index 0000000..ef198a2
--- /dev/null
+++ b/external/subpack/net/privoxy/files/privoxy.upgrade
@@ -0,0 +1,4 @@
+/etc/config/privoxy
+/etc/privoxy/user.action
+/etc/privoxy/user.filter
+/etc/privoxy/user.trust