#!/bin/bash # # rabbit Startup script for the RabbIT proxy server # # chkconfig: - 85 15 # description: RabbIT is a web proxy that speeds up web surfing over slow links by doing: # o Compress text pages to gzip streams. This reduces size by up to 75% # o Compress images to 10% jpeg. This reduces size by up to 95% # o Remove advertising # o Remove background images # o Cache filtered pages and images # o Uses keepalive if possible # o Easy and powerful configuration # o Multi threaded solution written in java # o Modular and easily extended # o Complete HTTP/1.1 compliance # config: /etc/RabbIT/access # config: /etc/RabbIT/allowed # config: /etc/RabbIT/cache_only.conf # config: /etc/RabbIT/empty.conf # config: /etc/RabbIT/nocache.conf # config: /etc/RabbIT/rabbit.conf # config: /etc/RabbIT/users # pidfile: /var/run/RabbIT.pid # ### BEGIN INIT INFO # Provides: rabbit # Required-Start: $local_fs $remote_fs $network $named # Required-Stop: $local_fs $remote_fs $network # Should-Start: distcache # Default-Stop: 0 1 6 # Short-Description: Start and stop the RabbIT proxy server # Description: RabbIT is a web proxy that speeds up web surfing over slow links by doing: # o Compress text pages to gzip streams. This reduces size by up to 75% # o Compress images to 10% jpeg. This reduces size by up to 95% # o Remove advertising # o Remove background images # o Cache filtered pages and images # o Uses keepalive if possible # o Easy and powerful configuration # o Multi threaded solution written in java # o Modular and easily extended # o Complete HTTP/1.1 compliance ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions bin='/usr/bin/RabbIT' prog='RabbIT proxy' pidfile=${PIDFILE-/var/run/rabbit.pid} lockfile=${LOCKFILE-/var/lock/subsys/rabbit} HTDOCS_DIR="{{HTDOCS}}" USER='rabbit' RETVAL=0 start(){ echo -n $"Starting $prog: " daemon +15 --pidfile="$pidfile" --user="$USER" sh -c "cd \"$HTDOCS_DIR\"; exec \"$bin\" 2>&1 >> /var/log/RabbIT/main_run.log &" RETVAL=$? echo if [ 0 -eq $RETVAL ]; then touch ${lockfile} #Pid of parent sh script p=$( __pids_pidof "$bin" ) [ -n $p ] && echo "Error: pid not found" && exit 1 # Pid of child. Real java process!!! Idea from: http://209.85.129.132/search?q=cache:QnI67WuZkRcJ:www.experts-exchange.com/Programming/System/Linux/Q_20943601.html+kill+all+childs&cd=14&hl=en&ct=clnk p=$(ps axef -o ppid,pid | sed -nr "s#^$p (.+)\$#\1#p") echo $p > "$pidfile" fi return $RETVAL } stop(){ echo -n $"Stopping $prog: " killproc -p ${pidfile} RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $bin RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f ${pidfile} ] ; then stop start fi ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|status}" RETVAL=3 esac exit $RETVAL