Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Morloth
TinyProxy
tinyproxy.init.rh
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tinyproxy.init.rh of Package TinyProxy
#!/bin/sh ### BEGIN INIT INFO # Provides: tinyproxy # Required-Start: $remote_fs $syslog $network # Should-Start: $all # Required-Stop: $remote_fs $syslog $network # Default-Start: 3 5 # Default-Stop: 0 1 2 4 6 # Short-Description: Start, stop script # Description: initialize script for NetpoliceTiny ### END INIT INFO # # NetpoliceTiny init.d script # Author: CAIR <tinyproxy@support.cair.ru> ############## Required-Start: $remote_fs $network $syslog PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin CONFIG=/etc/tinyproxy.conf # Configure file DAEMON=/usr/sbin/tinyproxy # Introduce the server's location here DESC=tinyproxy # Introduce a short description here NAME=tinyproxy # Introduce the short server's name here FLAGS="-f /etc/tinyproxy.filter.conf" IPT= # Path to iptables # include function if [ -f /etc/init.d/functions ]; then . /etc/init.d/functions fi test -f $DAEMON || exit 0 set -e # assert pidfile directory and permissions PIDFILE=$(grep -i '^PidFile[[:space:]]' "$CONFIG" | awk '{print $2}' |\ sed -e 's/"//g') [ -z "$PIDFILE" ] && PIDFILE=/var/run/"$NAME/$NAME".pid PIDDIR=`dirname "$PIDFILE"` if [ "$1" != "stop" ]; then if [ -f "$CONFIG" ]; then USER=$(grep -i '^User[[:space:]]' "$CONFIG" | awk '{print $2}') GROUP=$(grep -i '^Group[[:space:]]' "$CONFIG" | awk '{print $2}') PORT=$(grep -i '^Port[[:space:]]' "$CONFIG" | awk '{print $2}') LOGFILE=$(grep -i '^LogFile[[:space:]]' "$CONFIG" | awk '{print $2}' |\ sed -e 's/"//g') if [ -n "$PIDDIR" -a "$PIDDIR" != "/var/run" ]; then if [ ! -d "$PIDDIR" ]; then mkdir "$PIDDIR" fi if [ "$USER" ]; then chown "$USER" "$PIDDIR" fi if [ "$GROUP" ]; then chgrp "$GROUP" "$PIDDIR" fi fi fi fi setup_rules() { echo -n "Add IPtables rules..." $IPT -t nat -N in $IPT -t nat -N out $IPT -t nat -A PREROUTING -p tcp -m tcp --sport 1024:65535 --dport 80 -j in $IPT -t nat -A OUTPUT -p tcp -m tcp --sport 32768:61000 --dport 80 -j out $IPT -t nat -A in -p tcp -j REDIRECT --to-ports $PORT $IPT -t nat -A out -m owner --uid-owner $USER -j RETURN $IPT -t nat -A out -d 127.0.0.1/32 -j RETURN $IPT -t nat -A out -p tcp -j REDIRECT --to-ports $PORT # echo "Done" success echo } unsetup_rules() { echo -n "Remove IPtables rules..." $IPT -t nat -F in $IPT -t nat -F out $IPT -t nat -D PREROUTING -p tcp -m tcp --sport 1024:65535 --dport 80 -j in $IPT -t nat -D OUTPUT -p tcp -m tcp --sport 32768:61000 --dport 80 -j out $IPT -t nat -X in $IPT -t nat -X out # echo "Done" success echo } case "$1" in start) setup_rules echo -n "Starting $NAME:" $DAEMON $FLAGS -c $CONFIG && success || failure RETVAL=$? echo ;; stop) unsetup_rules echo -n "Stopping $NAME:" #kill -s TERM `cat $PIDFILE` killproc -p $PIDFILE $DAEMON -TERM || failure $"Stopping $DAEMON" echo ;; reload|force-reload) echo "Reloading $NAME configuration files." killproc -p $PIDFILE $DAEMON -HUP || failure $"Reloading $DAEMON" RETVAL=$? echo ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2 exit 1 ;; esac exit $RETVAL
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor