|
Matt Domsch |
8ba2153 |
#!/bin/sh
|
|
Matt Domsch |
8ba2153 |
#
|
|
Matt Domsch |
8ba2153 |
# cntlmd: Start/stop the cntlm proxy.
|
|
Matt Domsch |
8ba2153 |
#
|
|
Matt Domsch |
8ba2153 |
# chkconfig: - 26 89
|
|
Matt Domsch |
8ba2153 |
# Description: Cntlm is meant to be given your proxy address and becomming
|
|
Matt Domsch |
8ba2153 |
# the primary proxy then, listening on a selected local port.
|
|
Matt Domsch |
8ba2153 |
# You point all your proxy-aware programs to it and don't ever
|
|
Matt Domsch |
8ba2153 |
# have to deal with proxy authentication again.
|
|
Matt Domsch |
8ba2153 |
#
|
|
Matt Domsch |
8ba2153 |
### BEGIN INIT INFO
|
|
Matt Domsch |
8ba2153 |
# Provides: cntlm
|
|
Matt Domsch |
8ba2153 |
# Required-Start: $syslog $network $time
|
|
Matt Domsch |
8ba2153 |
# Required-Stop: $syslog $network $time
|
|
Matt Domsch |
8ba2153 |
# Short-Description: Authenticating HTTP accelerator for NTLM secured proxies
|
|
Matt Domsch |
8ba2153 |
# Description: Cntlm is meant to be given your proxy address and becomming
|
|
Matt Domsch |
8ba2153 |
# the primary proxy then, listening on a selected local port.
|
|
Matt Domsch |
8ba2153 |
# You point all your proxy-aware programs to it and don't ever
|
|
Matt Domsch |
8ba2153 |
# have to deal with proxy authentication again.
|
|
Matt Domsch |
8ba2153 |
### END INIT INFO
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Determining Linux RedHat/SuSE
|
|
Matt Domsch |
8ba2153 |
#
|
|
Matt Domsch |
8ba2153 |
# /etc/redhat-release
|
|
Matt Domsch |
8ba2153 |
# /etc/SuSE-release
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
SuSE=false
|
|
Matt Domsch |
8ba2153 |
RedHat=false
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if [ -f /etc/SuSE-release ]; then
|
|
Matt Domsch |
8ba2153 |
SuSE=true
|
|
Matt Domsch |
8ba2153 |
elif [ -f /etc/redhat-release ]; then
|
|
Matt Domsch |
8ba2153 |
RedHat=true
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
echo "Error: your platform is not supported by $0" > /dev/stderr
|
|
Matt Domsch |
8ba2153 |
exit 1
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Source function library SuSE/RedHat.
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
if [ -f /lib/lsb/init-functions ]; then
|
|
Matt Domsch |
8ba2153 |
. /lib/lsb/init-functions
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
echo "Error: your platform is not supported by $0" > /dev/stderr
|
|
Matt Domsch |
8ba2153 |
exit 1
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
if [ -f /etc/init.d/functions ]; then
|
|
Matt Domsch |
8ba2153 |
. /etc/init.d/functions
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
echo "Error: your platform is not supported by $0" > /dev/stderr
|
|
Matt Domsch |
8ba2153 |
exit 1
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
[ -r /etc/sysconfig/cntlmd ] && . /etc/sysconfig/cntlmd
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# First reset status of this service SuSE/RedHat
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
rc_reset
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
RETVAL=0
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Return values acc. to LSB for all commands but status:
|
|
Matt Domsch |
8ba2153 |
# 0 - success
|
|
Matt Domsch |
8ba2153 |
# 1 - generic or unspecified error
|
|
Matt Domsch |
8ba2153 |
# 2 - invalid or excess argument(s)
|
|
Matt Domsch |
8ba2153 |
# 3 - unimplemented feature (e.g. "reload")
|
|
Matt Domsch |
8ba2153 |
# 4 - insufficient privilege
|
|
Matt Domsch |
8ba2153 |
# 5 - program is not installed
|
|
Matt Domsch |
8ba2153 |
# 6 - program is not configured
|
|
Matt Domsch |
8ba2153 |
# 7 - program is not running
|
|
Matt Domsch |
8ba2153 |
#
|
|
Matt Domsch |
8ba2153 |
# Note that starting an already running service, stopping
|
|
Matt Domsch |
8ba2153 |
# or restarting a not-running service as well as the restart
|
|
Matt Domsch |
8ba2153 |
# with force-reload (in case signalling is not supported) are
|
|
Matt Domsch |
8ba2153 |
# considered a success.
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Shell functions sourced from /etc/rc.status only on SuSE Linux:
|
|
Matt Domsch |
8ba2153 |
# rc_check check and set local and overall rc status
|
|
Matt Domsch |
8ba2153 |
# rc_status check and set local and overall rc status
|
|
Matt Domsch |
8ba2153 |
# rc_status -v ditto but be verbose in local rc status
|
|
Matt Domsch |
8ba2153 |
# rc_status -v -r ditto and clear the local rc status
|
|
Matt Domsch |
8ba2153 |
# rc_failed set local and overall rc status to failed
|
|
Matt Domsch |
8ba2153 |
# rc_failed <num> set local and overall rc status to <num><num>
|
|
Matt Domsch |
8ba2153 |
# rc_reset clear local rc status (overall remains)
|
|
Matt Domsch |
8ba2153 |
# rc_exit exit appropriate to overall rc status
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
test -f $DAEMON || exit 5
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
start() {
|
|
Matt Domsch |
8ba2153 |
# Start daemons.
|
|
Matt Domsch |
8ba2153 |
echo -n "Starting $DESC: "
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
startproc -p $PIDFILE $DAEMON $OPTARGS 2>/dev/null
|
|
Matt Domsch |
8ba2153 |
rc_status -v
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
daemon cntlm $OPTARGS 2>/dev/null
|
|
Matt Domsch |
8ba2153 |
RETVAL=$?
|
|
Matt Domsch |
8ba2153 |
echo
|
|
Matt Domsch |
8ba2153 |
[ $RETVAL -eq 0 ] && touch $LOCKFILE
|
|
Matt Domsch |
8ba2153 |
return $RETVAL
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
}
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
stop() {
|
|
Matt Domsch |
8ba2153 |
echo -n "Shutting down $DESC: "
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
## Stop daemon with killproc(8) and if this fails
|
|
Matt Domsch |
8ba2153 |
## set echo the echo return value.
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
killproc -p $PIDFILE -TERM $DAEMON
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Remember status and be verbose
|
|
Matt Domsch |
8ba2153 |
rc_status -v
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
killproc cntlm
|
|
Matt Domsch |
8ba2153 |
RETVAL=$?
|
|
Matt Domsch |
8ba2153 |
echo
|
|
Matt Domsch |
8ba2153 |
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
|
|
Matt Domsch |
8ba2153 |
return $RETVAL
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
}
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# See how we were called.
|
|
Matt Domsch |
8ba2153 |
case "$1" in
|
|
Matt Domsch |
8ba2153 |
start)
|
|
Matt Domsch |
8ba2153 |
start
|
|
Matt Domsch |
8ba2153 |
;;
|
|
Matt Domsch |
8ba2153 |
stop)
|
|
Matt Domsch |
8ba2153 |
stop
|
|
Matt Domsch |
8ba2153 |
;;
|
|
Matt Domsch |
8ba2153 |
status)
|
|
Matt Domsch |
8ba2153 |
echo -n "Checking for $DESC: "
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
## Check status with checkproc(8), if process is running
|
|
Matt Domsch |
8ba2153 |
## checkproc will return with exit status 0.
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# Status has a slightly different for the status command:
|
|
Matt Domsch |
8ba2153 |
# 0 - service running
|
|
Matt Domsch |
8ba2153 |
# 1 - service dead, but /var/run/ pid file exists
|
|
Matt Domsch |
8ba2153 |
# 2 - service dead, but /var/lock/ lock file exists
|
|
Matt Domsch |
8ba2153 |
# 3 - service not running
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
# NOTE: checkproc returns LSB compliant status values.
|
|
Matt Domsch |
8ba2153 |
checkproc -p $PIDFILE $DAEMON
|
|
Matt Domsch |
8ba2153 |
rc_status -v
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
status cntlm
|
|
Matt Domsch |
8ba2153 |
fi
|
|
Matt Domsch |
8ba2153 |
;;
|
|
Matt Domsch |
8ba2153 |
restart|reload)
|
|
Matt Domsch |
8ba2153 |
stop
|
|
Matt Domsch |
8ba2153 |
start
|
|
Matt Domsch |
8ba2153 |
;;
|
|
Matt Domsch |
8ba2153 |
*)
|
|
Matt Domsch |
8ba2153 |
echo $"Usage: $0 {start|stop|restart|status}"
|
|
Matt Domsch |
8ba2153 |
exit 1
|
|
Matt Domsch |
8ba2153 |
esac
|
|
Matt Domsch |
8ba2153 |
|
|
Matt Domsch |
8ba2153 |
if $SuSE; then
|
|
Matt Domsch |
8ba2153 |
rc_exit
|
|
Matt Domsch |
8ba2153 |
else
|
|
Matt Domsch |
8ba2153 |
exit $RETVAL
|
|
Matt Domsch |
8ba2153 |
fi
|