Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Morloth
TinyProxy
debian.tinyproxy.init
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File debian.tinyproxy.init of Package TinyProxy
#!/bin/sh ### BEGIN INIT INFO # Provides: netpolicetiny # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start, stop scrippt # Description: initialize script for NetpoliceTiny ### END INIT INFO # # NetpoliceTiny init.d script # Author: CAIR <support@cair.ru> # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin CONFIG=/etc/netpolicetiny.conf # Configure file CONFIG_FILTER=/etc/netpolicetiny.filter.conf # Configure file DAEMON=/usr/sbin/netpolicetiny # Introduce the server's location here DESC=netpolicetiny # Introduce a short description here NAME=netpolicetiny # Introduce the short server's name here FLAGS="-f $CONFIG_FILTER" IPT= # Path to iptables if [ -r /etc/default/netpolicetiny ]; then . /etc/default/netpolicetiny fi test -f $DAEMON || exit 0 set -e # assert pidfile directory and permissions 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}') PIDFILE=$(grep -i '^PidFile[[:space:]]' "$CONFIG" | awk '{print $2}' |\ sed -e 's/"//g') PIDDIR=`dirname "$PIDFILE"` 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" } 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" } case "$1" in start) setup_rules echo -n "Starting $DESC: " start-stop-daemon --start --quiet -o --exec $DAEMON -- $FLAGS echo "$NAME." ;; stop) unsetup_rules echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet -o --exec $DAEMON echo "$NAME." ;; reload|force-reload) echo "Reloading $DESC configuration files." start-stop-daemon --stop --signal 1 --quiet -o --exec $DAEMON ;; restart) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet -o --exec $DAEMON sleep 1 start-stop-daemon --start --quiet -o --exec $DAEMON -- $FLAGS echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 exit 1 ;; esac exit 0
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