X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=privoxy-generic.init;h=d9991f3be9ac648921c4c42b252fe151738f3aa4;hb=791dc4ba995831c0d1bb2032e1f50e8f4537f186;hp=a6d07ae814378713b026af60b3971ffe4dd6a484;hpb=d02bbf657292ae806414d0b3dfe1b0d63d1ac520;p=privoxy.git diff --git a/privoxy-generic.init b/privoxy-generic.init index a6d07ae8..d9991f3b 100755 --- a/privoxy-generic.init +++ b/privoxy-generic.init @@ -39,6 +39,23 @@ # # Revisions : # $Log: privoxy-generic.init,v $ +# Revision 1.6 2006/07/18 14:48:47 david__schmidt +# Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch) +# with what was really the latest development (the v_3_0_branch branch) +# +# Revision 1.5.2.1 2002/10/17 17:04:22 hal9 +# Add from main trunk. Will be needed for make install. +# +# Revision 1.5 2002/10/17 17:01:29 hal9 +# Set paths to match the defaults for a root install. Force remove PIDFILE on +# stop. +# +# Revision 1.4 2002/09/11 01:15:02 hal9 +# Fix typo in variable. Now tested on Solaris and Linux, with defaults. +# +# Revision 1.3 2002/09/11 01:09:14 hal9 +# Better handling of pidfile, and process owner. +# # Revision 1.2 2002/09/08 20:27:58 hal9 # -Rewrote script config section. # -Added comments to script. @@ -67,10 +84,10 @@ P_NAME=Privoxy # Path to executable. P_DAEMON=privoxy # Full path to location of Privoxy config file. -P_CONF_FILE=./config +P_CONF_FILE=/usr/local/etc/privoxy/config # Full path to PID file location. Location must be writable by -# whoever runs this script. -P_PIDFILE=`pwd`/privoxy.pid +# whoever runs this script and by Privoxy itself. +P_PIDFILE=/var/run/privoxy.pid # If uncommented, this script will try to run as USER=privoxy, which # may require special handling of config, *.action, trust, logfile, # jarfile, and pidfile. @@ -78,10 +95,25 @@ P_USER=privoxy # If a privoxy user is specified, lets try that. /bin/sh does not seem to # know about $UID. -if [ "$USER" = "root" ] && [ -n "$P_USER" ] && id $P_USER >/dev/null; then - P_OWNER=$P_USER -else - P_OWNER=$USER +if [ 0 = `id -u` ]; then + if [ -n "$P_USER" ]; then + id $P_USER 2>/dev/null >/dev/null + if [ $? -eq 0 ]; then + P_USER_SETTINGS="--user $P_USER" + else + echo "User $P_USER doesn't exist, exiting." + exit 1 + fi + else + # The user has sufficient rights, but $P_USER isn't set + echo "Running Privoxy as root is not recommended!" + P_USER_SETTINGS="" + fi +else + # The user has insufficient rights to run Privoxy as $P_USER + # and may not be able to write or delete the PID file. + echo "You aren't root, expect trouble!" + P_USER_SETTINGS="" fi if [ ! -f $P_CONF_FILE ]; then @@ -94,14 +126,14 @@ case "$1" in start) if [ -f $P_PIDFILE ]; then if kill -0 `cat $P_PIDFILE`; then - echo "Error: $NAME is already running, exiting." + echo "Error: $P_NAME is already running, exiting." exit 1 else rm -f $P_PIDFILE fi fi - $P_DAEMON --pidfile $P_PIDFILE --user $P_OWNER $P_CONF_FILE 2>/dev/null + $P_DAEMON --pidfile $P_PIDFILE $P_USER_SETTINGS $P_CONF_FILE 2>/dev/null if [ $? -eq 0 ]; then echo "Starting $P_NAME, OK." @@ -118,7 +150,7 @@ case "$1" in stop) test ! -f $P_PIDFILE && echo "No $P_PIDFILE file found, exiting." && exit 1 - kill `cat $P_PIDFILE` &&\ + kill `cat $P_PIDFILE` && rm -f $P_PIDFILE && \ echo "Stopping $P_NAME, OK." || echo "Stopping $P_NAME, failed." ;;