Quellcode durchsuchen

Merge pull request #910 from chris5560/master-privoxy

privoxy: remove upgrade handling, conffile and initscript fixes
Steven Barth vor 10 Jahren
Ursprung
Commit
09a5633817

+ 30
- 99
net/privoxy/Makefile Datei anzeigen

@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=privoxy
11 11
 PKG_VERSION:=3.0.23
12
-PKG_RELEASE:=2
12
+PKG_RELEASE:=3
13 13
 
14
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-stable-src.tar.gz
14
+PKG_SOURCE:=privoxy-$(PKG_VERSION)-stable-src.tar.gz
15 15
 PKG_SOURCE_URL:=@SF/ijbswa
16 16
 PKG_MD5SUM:=bbe47d5ff1a54d9f9fc93a160532697f
17
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-stable
17
+PKG_BUILD_DIR:=$(BUILD_DIR)/privoxy-$(PKG_VERSION)-stable
18 18
 PKG_FIXUP:=autoreconf
19 19
 PKG_INSTALL:=1
20 20
 
@@ -63,116 +63,47 @@ CONFIGURE_ARGS += \
63 63
 # needed otherwise errors during compile
64 64
 MAKE_FLAGS:=
65 65
 
66
-define Build/Install
67
-	$(call Build/Install/Default,)
68
-	# rename original sample config from pkg_source to save existing one during install
69
-	mv $(PKG_INSTALL_DIR)/etc/privoxy/config $(PKG_INSTALL_DIR)/etc/privoxy/config.privoxy
70
-endef
71
-
72
-# "/etc/privoxy/config" temporary needed if updating from old version
73 66
 define Package/$(PKG_NAME)/conffiles
74 67
 /etc/config/privoxy
75
-/etc/privoxy/config
68
+/etc/privoxy/user.action
69
+/etc/privoxy/user.filter
70
+/etc/privoxy/user.trust
76 71
 endef
77 72
 
78 73
 define Package/$(PKG_NAME)/preinst
79 74
 	#!/bin/sh
80
-	# if run within buildroot exit
81
-	[ -n "$${IPKG_INSTROOT}" ] && exit 0
75
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0	# if run within buildroot exit
76
+
82 77
 	# stop service if PKG_UPGRADE
83 78
 	[ "$${PKG_UPGRADE}" = "1" ] && /etc/init.d/privoxy stop >/dev/null 2>&1
79
+		
84 80
 	exit 0	# supress errors from stop command
85 81
 endef
86 82
 
87 83
 define Package/$(PKG_NAME)/install
88
-	$(INSTALL_DIR) $(1)/usr/sbin
89
-	$(CP) $(PKG_INSTALL_DIR)/usr/sbin/privoxy $(1)/usr/sbin/
90
-	$(INSTALL_DIR) $(1)/etc/init.d
91
-	$(INSTALL_BIN) ./files/privoxy.init $(1)/etc/init.d/privoxy
92
-	$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
93
-	$(INSTALL_BIN) ./files/privoxy.hotplug $(1)/etc/hotplug.d/iface/80-privoxy
94
-
95
-	$(INSTALL_DIR) $(1)/etc/privoxy
96
-	$(CP) $(PKG_INSTALL_DIR)/etc/privoxy/* $(1)/etc/privoxy/
97
-	# temporary needed if updating from old version
98
-	# otherwise old config file will be delete by opkg
99
-	$(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config
100
-	# create .old file to be removed with next pacakge builds during update
101
-	$(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config.old
102
-	# copy NEW config
103
-	$(INSTALL_DIR) $(1)/etc/config
104
-	$(INSTALL_CONF) ./files/privoxy.config $(1)/etc/config/privoxy
105
-endef
106
-
107
-define Package/$(PKG_NAME)/postinst
108
-	#!/bin/sh
109
-
110
-	# if fresh install we don't need old config file in privoxy directory
111
-	[ "$${PKG_UPGRADE}" = "0" ] && rm -f /etc/privoxy/config
112
-
113
-	# if run within buildroot exit here
114
-	[ -n "$${IPKG_INSTROOT}" ] && exit 0
115
-
116
-	# if PKG_UPGRADE then build uci configuration
117
-	# from existing(?) old /etc/privoxy/config file
118
-	if [ "$${PKG_UPGRADE}" = "1" -a -f /etc/privoxy/config ]; then
119
-
120
-		echo "converting OLD config to NEW uci configuration"
121
-
122
-		SECTION="privoxy.privoxy"
123
-		CFGFILE=/etc/privoxy/config
124
-
125
-		echo -n > /etc/config/privoxy		# clear/create uci configuration file
126
-		cp -f $${CFGFILE} $${CFGFILE}.old	# save old configuration
127
-
128
-		# cleanup
129
-		sed -i 's/^[ \t]*//;s/[ \t]*$$//' $${CFGFILE}	# remove invisible chars at beginning and end of lines
130
-		sed -i '/^#/d' $${CFGFILE}			# remove lines with "#"
131
-		sed -i '/^$$/d' $${CFGFILE}			# remove empty lines
132
-
133
-		uci -q set $${SECTION}="privoxy"		# create section
134
-
135
-		cat $${CFGFILE} | while read LINE; do
136
-			# option is first parameter; uci did not like "-" in option names
137
-			OPT=$$(echo $${LINE} | awk '{print $$1}' | sed 's/-/_/g')
138
-			VAL=$$(echo $${LINE} | awk '{print $$2}')
139
-			case $${OPT} in
140
-				# debug 1024 => debug_1024 '1'
141
-				debug)
142
-					uci -q set $${SECTION}.debug_$${VAL}="1"
143
-					;;
144
-				# handle list values; splitted case for better reading
145
-				actionsfile|filterfile|listen_address)
146
-					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
147
-					;;
148
-				permit_access|deny_access)
149
-					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
150
-					;;
151
-				trust_info_url|forward)
152
-					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
153
-					;;
154
-				forward_socks4|forward_socks4a)
155
-					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
156
-					;;
157
-				forward_socks5|forward_socks5t)
158
-					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
159
-					;;
160
-				# all others are normal options
161
-				*)
162
-					uci -q set $${SECTION}.$${OPT}="$${VAL}"
163
-					;;
164
-			esac
165
-		done
166
-		uci -q commit privoxy	# commit changes
167
-		rm -f $${CFGFILE}	# remove old configuration file
84
+	if [ -f $(PKG_INSTALL_DIR)/etc/privoxy/trust ]; then \
85
+		mv -f $(PKG_INSTALL_DIR)/etc/privoxy/trust $(PKG_INSTALL_DIR)/etc/privoxy/user.trust; \
86
+	fi
87
+	if [ -f $(PKG_INSTALL_DIR)/etc/privoxy/config ]; then \
88
+		rm -f $(PKG_INSTALL_DIR)/etc/privoxy/config; \
168 89
 	fi
169 90
 
170
-	# set permissions to privoxy group
171
-	echo "setting permissions"
172
-	chgrp -R privoxy /etc/privoxy/*
173
-	chmod 664 /etc/privoxy/*
174
-	chmod 755 /etc/privoxy/templates
175
-	chmod 644 /etc/privoxy/templates/*
91
+	$(INSTALL_DIR) \
92
+		$(1)/usr/sbin\
93
+		$(1)/etc/privoxy/templates
94
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/privoxy $(1)/usr/sbin/
95
+	find $(PKG_INSTALL_DIR)/etc/privoxy/templates -maxdepth 1 -type f \
96
+		-exec $(INSTALL_DATA) -t $(1)/etc/privoxy/templates {} \;
97
+	find $(PKG_INSTALL_DIR)/etc/privoxy -maxdepth 1 -type f \
98
+		-exec install -m0664 -t $(1)/etc/privoxy {} \;
99
+
100
+	$(INSTALL_DIR) \
101
+		$(1)/etc/init.d \
102
+		$(1)/etc/hotplug.d/iface \
103
+		$(1)/etc/config
104
+	$(INSTALL_BIN)  ./files/privoxy.init $(1)/etc/init.d/privoxy
105
+	$(INSTALL_BIN)  ./files/privoxy.hotplug $(1)/etc/hotplug.d/iface/80-privoxy
106
+	$(INSTALL_CONF) ./files/privoxy.config $(1)/etc/config/privoxy
176 107
 endef
177 108
 
178 109
 $(eval $(call BuildPackage,$(PKG_NAME)))

+ 6
- 5
net/privoxy/files/privoxy.config Datei anzeigen

@@ -1,13 +1,12 @@
1
-# this file support all available configuration options of
2
-# Privoxy web-proxy
1
+# this file support all available configuration options of Privoxy web-proxy
3 2
 # the scripts move all options to the final privoxy readable configuration file
4 3
 #
5 4
 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6 5
 # !!! privoxy uses "-" in option names but uci only support "_"         !!!
7 6
 # !!! privoxy "listen-address" must be uci "listen_address"             !!!
8 7
 # !!!                                                                   !!!
9
-# !!! if you add entries please use                                      !!!
10
-# !!! option for options with one parameter (option confdir)             !!!
8
+# !!! if you add entries please use                                     !!!
9
+# !!! option for options with one parameter (option confdir)            !!!
11 10
 # !!! list   for options with multiple parameters (list listen_address) !!!
12 11
 # !!!                                                                   !!!
13 12
 # !!! special handling for debug option                                 !!!
@@ -19,10 +18,11 @@ config	privoxy	'privoxy'
19 18
 	option	logdir		'/var/log'
20 19
 	option	logfile		'privoxy.log'
21 20
 	list	filterfile	'default.filter'
21
+#	list	filterfile	'user.filter'
22 22
 	list	actionsfile	'match-all.action'
23 23
 	list	actionsfile	'default.action'
24 24
 #	list	actionsfile	'user.action'
25
-	list	listen_address	'127.0.0.1:8118'
25
+#	list	listen_address	'127.0.0.1:8118'
26 26
 	list	listen_address	'192.168.1.1:8118'
27 27
 	option	toggle		'1'
28 28
 	option	enable_remote_toggle	'1'
@@ -38,6 +38,7 @@ config	privoxy	'privoxy'
38 38
 	option	socket_timeout		'300'
39 39
 	list	permit_access		'192.168.1.0/24'
40 40
 	option	debug_1		'0'
41
+	option	debug_512	'1'
41 42
 	option	debug_1024	'0'
42 43
 	option	debug_4096	'1'
43 44
 	option	debug_8192	'1'

+ 52
- 21
net/privoxy/files/privoxy.init Datei anzeigen

@@ -8,9 +8,6 @@ CFGFILE=/var/etc/privoxy.conf
8 8
 CFGTEMP=/var/etc/privoxy.conf.tmp
9 9
 
10 10
 _uci2conf() {
11
-	local _LOGDIR="/var/log"	# set default
12
-	local _LOGFILE="privoxy.log"	# set default
13
-
14 11
 	# redefined callback for options when calling config_load
15 12
 	option_cb()
16 13
 	{
@@ -19,21 +16,19 @@ _uci2conf() {
19 16
 		local __OPT="$1"
20 17
 		local __VAL="$2"
21 18
 		case $__OPT in
22
-			logdir)		# logdir handled later
23
-				_LOGDIR="$__VAL"  ;;
24
-			logfile)	# logfile handled later
25
-				_LOGFILE="$__VAL" ;;
19
+			confdir|templdir|temporary_directory|logdir|logfile)
20
+				# needs to be handled separately because we need to set permissions
21
+				# AND needs to be defined first because of a BUG inside privoxy
22
+				# require directories to be defined first inside config 
23
+				;;
24
+			debug_*)
25
+				[ $__VAL -eq 0 ] && return	# not set ignore
26
+				echo -e "debug\t$(echo $__OPT | sed -e 's#debug_##g')" >> $CFGTEMP ;;
26 27
 			*)
27 28
 				# detect list options (LENGTH) and ignore
28 29
 				echo $__OPT | grep -i "_LENGTH" >/dev/null 2>&1 && return
29 30
 				# detect list options (ITEM) and ignore
30 31
 				echo $__OPT | grep -i "_ITEM" >/dev/null 2>&1 && __OPT=$(echo $__OPT | sed -e "s#_ITEM.##g")
31
-				# filter debug_*
32
-				echo $__OPT | grep -i "debug_" >/dev/null 2>&1 && {
33
-					[ $__VAL -eq 0 ] && return	# not set ignore
34
-					__VAL=$(echo $__OPT | sed -e "s#debug_##g")
35
-					__OPT="debug"
36
-				}
37 32
 				# uci only accept "_" but we need "-"
38 33
 				local __OPT=$(echo $__OPT | sed -e "s#_#-#g")
39 34
 				# write to config
@@ -42,9 +37,11 @@ _uci2conf() {
42 37
 		esac
43 38
 	}
44 39
 
40
+	# temporary config file
41
+	# privoxy need read access
45 42
 	mkdir -m0755 -p /var/etc
46
-	echo "" > $CFGTEMP	# create tmp config file
47
-	chmod 644 $CFGTEMP	# garantee that privoxy can read
43
+	echo "" > $CFGTEMP
44
+	chmod 644 $CFGTEMP
48 45
 	chgrp privoxy $CFGTEMP
49 46
 
50 47
 	echo '### AUTO-GENERATED CONFIGURATION'	   >> $CFGTEMP
@@ -53,19 +50,53 @@ _uci2conf() {
53 50
 	echo '### SEE /etc/config/privoxy INSTEAD' >> $CFGTEMP
54 51
 	echo ''					   >> $CFGTEMP
55 52
 
56
-	config_load privoxy	# calling above option_cb()
57
-
58
-	# write logdir/logfile to config
59
-	echo -e "logdir\t$_LOGDIR" >> $CFGTEMP
60
-	echo -e "logfile\t$_LOGFILE" >> $CFGTEMP
53
+	# confdir
54
+	# privoxy needs read access (possibly write access)
55
+	_CONFDIR=$(uci -q get privoxy.privoxy.confdir) || _CONFDIR="/etc/privoxy"
56
+	chmod 755 $_CONFDIR
57
+	chmod 664 $_CONFDIR/*
58
+	chgrp privoxy $_CONFDIR $_CONFDIR/*
59
+	echo -e "confdir\t$_CONFDIR" >> $CFGTEMP
60
+
61
+	# templdir
62
+	# privoxy need read access
63
+	_TEMPLDIR=$(uci -q get privoxy.privoxy.templdir)	# no default needed
64
+	if [ -z "$_TEMPLDIR" ]; then
65
+		chmod 755 $_CONFDIR/templates
66
+		chmod 644 $_CONFDIR/templates/*
67
+		chgrp privoxy $_CONFDIR/templates $_CONFDIR/templates/*
68
+	else
69
+		chmod 755 $_TEMPLDIR
70
+		chmod 644 $_TEMPLDIR/*
71
+		chgrp privoxy $_TEMPLDIR $_TEMPLDIR/*
72
+		echo -e "templdir\t$_TEMPLDIR" >> $CFGTEMP
73
+	fi
61 74
 
62
-	# create logfile and set permissions
75
+	# logdir and logfile
76
+	# privoxy needs read/write access
77
+	_LOGDIR=$(uci -q get privoxy.privoxy.logdir)   || _LOGDIR="/var/log"
78
+	_LOGFILE=$(uci -q get privoxy.privoxy.logfile) || _LOGFILE="privoxy.log"
79
+	mkdir -m0755 -p $_LOGDIR
63 80
 	touch $_LOGDIR/$_LOGFILE
64 81
 	chmod 664 $_LOGDIR/$_LOGFILE
65 82
 	chown privoxy:privoxy $_LOGDIR/$_LOGFILE
83
+	echo -e "logdir\t$_LOGDIR" >> $CFGTEMP
84
+	echo -e "logfile\t$_LOGFILE" >> $CFGTEMP
85
+
86
+	# temporary-directory
87
+	# privoxy needs read/write access
88
+	_TMP_DIR=$(uci -q get privoxy.privoxy.temporary_directory)	# no default needed
89
+	if [ -n "$_TMP_DIR" ]; then
90
+		mkdir -m0750 -p $_TMP_DIR
91
+		chown privoxy:privoxy $_TMP_DIR
92
+		echo -e "temporary-directory\t$_TMP_DIR" >> $CFGTEMP
93
+	fi
94
+
95
+	config_load privoxy	# calling above option_cb() and write the rest into $CFGTEMP
66 96
 
67 97
 	# move temp to final privoxy readable configuration
68 98
 	mv -f $CFGTEMP $CFGFILE
99
+	return 0
69 100
 }
70 101
 
71 102
 boot() {

+ 0
- 33
net/privoxy/files/privoxy.oldconfig Datei anzeigen

@@ -1,33 +0,0 @@
1
-#
2
-# original configuration file used by privoxy
3
-# this is no longer supported by this package
4
-# it's converted and moved to uci configuration
5
-# please look at /etc/config/privoxy
6
-#
7
-confdir /etc/privoxy
8
-logdir /var/log
9
-logfile privoxy.log
10
-filterfile default.filter
11
-actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
12
-actionsfile default.action   # Main actions file
13
-#actionsfile user.action      # User customizations
14
-listen-address  127.0.0.1:8118
15
-toggle  1
16
-enable-remote-toggle  1
17
-enable-remote-http-toggle  0
18
-enable-edit-actions 1
19
-enforce-blocks 0
20
-buffer-limit 4096
21
-forwarded-connect-retries  0
22
-accept-intercepted-requests 0
23
-allow-cgi-request-crunching 0
24
-split-large-forms 0
25
-keep-alive-timeout 300
26
-socket-timeout 300
27
-permit-access  192.168.1.0/24
28
-debug   1    # show each GET/POST/CONNECT request
29
-debug   4096 # Startup banner and warnings
30
-debug   8192 # Errors - *we highly recommended enabling this*
31
-#admin-address privoxy-admin@example.com
32
-#proxy-info-url http://www.example.com/proxy-service.html
33
-