privoxy: moved to github and update to 3.0.22

- moved from oldpackages to github
- set maintainer
- update pkg source to new version 3.0.22
- run privoxy as non root user privoxy:privoxy
- using procd including network events to restart on changes
- log start and stop to syslog, privoxy not using syslog

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
Steven Barth
2014-12-08 20:40:47 +01:00
parent 3b8614c44b
commit eeabfeed8e
4 changed files with 368 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# 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 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_1024 '0'
option debug_4096 '1'
option debug_8192 '1'
+124
View File
@@ -0,0 +1,124 @@
#!/bin/sh /etc/rc.common
START=80
USE_PROCD=1
PIDFILE=/var/run/privoxy.pid
CFGFILE=/var/etc/privoxy.conf
CFGTEMP=/var/etc/privoxy.conf.tmp
_uci2conf() {
local _LOGDIR="/var/log" # set default
local _LOGFILE="privoxy.log" # set default
# redefined callback for options when calling config_load
option_cb()
{
# $1 name of variable
# $2 value
local __OPT="$1"
local __VAL="$2"
case $__OPT in
logdir) # logdir handled later
_LOGDIR="$__VAL" ;;
logfile) # logfile handled later
_LOGFILE="$__VAL" ;;
*)
# 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")
# filter debug_*
echo $__OPT | grep -i "debug_" >/dev/null 2>&1 && {
[ $__VAL -eq 0 ] && return # not set ignore
__VAL=$(echo $__OPT | sed -e "s#debug_##g")
__OPT="debug"
}
# uci only accept "_" but we need "-"
local __OPT=$(echo $__OPT | sed -e "s#_#-#g")
# write to config
echo -e "$__OPT\t$__VAL" >> $CFGTEMP
;;
esac
}
mkdir -m0755 -p /var/etc
echo "" > $CFGTEMP # create tmp config file
chmod 644 $CFGTEMP # garantee that privoxy can read
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
config_load privoxy # calling above option_cb()
# write logdir/logfile to config
echo -e "logdir\t$_LOGDIR" >> $CFGTEMP
echo -e "logfile\t$_LOGFILE" >> $CFGTEMP
# create logfile and set permissions
touch $_LOGDIR/$_LOGFILE
chmod 664 $_LOGDIR/$_LOGFILE
chown privoxy:privoxy $_LOGDIR/$_LOGFILE
# move temp to final privoxy readable configuration
mv -f $CFGTEMP $CFGFILE
}
# privoxy should auto-reload it's configuration
# but it only reload on next connect to one of the listen_address
# if we create a new listen_address privoxy never reload
reload_service() {
# so we restart here because rc.common reload_service only start without stopping
restart "$@"
# the following should normally work but see above
# _uci2conf # convert uci config
}
service_triggers() {
procd_add_reload_trigger "privoxy"
}
start_service() {
# redefined callback for sections when calling config_load
config_cb() {
# $1 type of config section
# $2 name of section
[ "$1" = "interface" ] && \
procd_add_interface_trigger interface.* $2 /etc/init.d/privoxy restart
}
_uci2conf # convert uci config
procd_open_instance
procd_set_param command /usr/sbin/privoxy
procd_append_param command --no-daemon # for procd run in foreground
procd_append_param command --pidfile $PIDFILE # set pid file
procd_append_param command --user privoxy.privoxy # set user
procd_append_param command $CFGFILE # config file
procd_set_param file $CFGFILE # set configration file
procd_open_trigger # we need a restart on interface events not a reload
config_load network # load network configuration and set trigger(s) in config_cb() above
procd_close_trigger
procd_close_instance
}
service_running() {
logger_trick() {
sleep 1 # give privoxy time to completely come up
logger -p daemon.notice -t "privoxy[$(cat $PIDFILE)]" "Service started successfully"
}
logger_trick &
}
stop_service() {
logger -p daemon.notice -t "privoxy[$(cat $PIDFILE)]" "Service shutdown"
}
+33
View File
@@ -0,0 +1,33 @@
#
# original configuration file used by privoxy
# this is no longer supported by this package
# it's converted and moved to uci configuration
# please look at /etc/config/privoxy
#
confdir /etc/privoxy
logdir /var/log
logfile privoxy.log
filterfile default.filter
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action # Main actions file
#actionsfile user.action # User customizations
listen-address 127.0.0.1:8118
toggle 1
enable-remote-toggle 1
enable-remote-http-toggle 0
enable-edit-actions 1
enforce-blocks 0
buffer-limit 4096
forwarded-connect-retries 0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 300
socket-timeout 300
permit-access 192.168.1.0/24
debug 1 # show each GET/POST/CONNECT request
debug 4096 # Startup banner and warnings
debug 8192 # Errors - *we highly recommended enabling this*
#admin-address privoxy-admin@example.com
#proxy-info-url http://www.example.com/proxy-service.html