aboutsummaryrefslogtreecommitdiff
path: root/net/privoxy/files
diff options
context:
space:
mode:
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>2014-12-23 10:50:51 +0100
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>2014-12-23 10:50:51 +0100
commit6aa05568b818594f73d9a148d37d8c5859c3c735 (patch)
tree75df1f02fa08e62777f08c28788280402895f76c /net/privoxy/files
parent45cb1f563f655af642cbcc9ca9f5eaec4c9ef295 (diff)
[privoxy] remove using procd
* go back to "old" initscript not using procd * privoxy running --no-daemon only logging to STDERR * procd do not support redirection of STDOUT/STDERR, '2>file' as a command parameter does not work Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Diffstat (limited to 'net/privoxy/files')
-rw-r--r--net/privoxy/files/privoxy.hotplug18
-rw-r--r--net/privoxy/files/privoxy.init91
2 files changed, 61 insertions, 48 deletions
diff --git a/net/privoxy/files/privoxy.hotplug b/net/privoxy/files/privoxy.hotplug
new file mode 100644
index 000000000..bd668017f
--- /dev/null
+++ b/net/privoxy/files/privoxy.hotplug
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# only (re-)start on ifup
+[ "$ACTION" = "ifup" ] || 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/net/privoxy/files/privoxy.init b/net/privoxy/files/privoxy.init
index 8ea6d6f5d..8ffc6f2c8 100644
--- a/net/privoxy/files/privoxy.init
+++ b/net/privoxy/files/privoxy.init
@@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common
START=80
-USE_PROCD=1
+STOP=20
PIDFILE=/var/run/privoxy.pid
CFGFILE=/var/etc/privoxy.conf
@@ -68,57 +68,52 @@ _uci2conf() {
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
+boot() {
+ return 0 # will be started by "iface" hotplug events
}
-service_triggers() {
- procd_add_reload_trigger "privoxy"
+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
+
+ # 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
}
-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 &
+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_service() {
- logger -p daemon.notice -t "privoxy[$(cat $PIDFILE)]" "Service shutdown"
+stop() {
+ local _PID=$(cat $PIDFILE 2>/dev/null)
+ kill -15 $_PID 2>/dev/null
+ sleep 1 # give time to shutdown
+ local _tmp=$(pgrep privoxy)
+ if [ -z "$_tmp" ]; then
+ logger -p daemon.notice -t "privoxy[$_PID]" "Shutdown successfully"
+ else
+ killall -9 privoxy
+ logger -p daemon.warn -t "privoxy[-----]" "Shutdown forced by KILL"
+ fi
+ return 0
}