96 lines
1.8 KiB
Text
96 lines
1.8 KiB
Text
|
#! /bin/bash
|
||
|
# setup echolink proxies - Rob Janssen
|
||
|
#
|
||
|
# /etc/init.d/elproxy
|
||
|
#
|
||
|
### BEGIN INIT INFO
|
||
|
# Provides: elproxy
|
||
|
# Required-Start: cron
|
||
|
# Required-Stop:
|
||
|
# Default-Start: 2 3 4 5
|
||
|
# Default-Stop: 0 1 6
|
||
|
# Description: Configure special network interface and start el proxies
|
||
|
### END INIT INFO
|
||
|
|
||
|
. /lib/lsb/init-functions
|
||
|
|
||
|
PROG="elproxy"
|
||
|
DAEMON=/home/elproxy/elproxy
|
||
|
CONFIG=/home/elproxy/ELProxy.conf
|
||
|
STATFILE=/dev/shm/elproxy
|
||
|
PIDFILE=/var/run/$PROG.pid
|
||
|
LOGFILE=/var/log/$PROG
|
||
|
ERRLOG=/var/log/$PROG.err
|
||
|
RUNASUSER=elproxy
|
||
|
ELPROXIF="dummy0"
|
||
|
ELPROXNET="44.137.75"
|
||
|
|
||
|
test -x $DAEMON || exit 5
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
echo "Starting elproxy daemon"
|
||
|
|
||
|
## Check about pid file
|
||
|
if [ -e $PIDFILE ]; then
|
||
|
if $0 status > /dev/null ; then
|
||
|
log_failure_msg "$PROG is already started; not starting"
|
||
|
return
|
||
|
else
|
||
|
log_progress_msg "[Removing stale PID file $PIDFILE]"
|
||
|
rm -f $PIDFILE
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
echo "Starting interface"
|
||
|
modprobe dummy
|
||
|
ifconfig $ELPROXIF $ELPROXNET.1/24 up
|
||
|
|
||
|
for i in {2..249}
|
||
|
do
|
||
|
ip addr add $ELPROXNET.$i/32 dev $ELPROXIF
|
||
|
done
|
||
|
|
||
|
echo "Starting proxies"
|
||
|
touch $LOGFILE
|
||
|
chown $RUNASUSER.$RUNASUSER $LOGFILE
|
||
|
sleep 2
|
||
|
|
||
|
start-stop-daemon --start --pidfile $PIDFILE --make-pidfile --chuid $RUNASUSER --startas $DAEMON -- $CONFIG >>$ERRLOG 2>&1
|
||
|
;;
|
||
|
|
||
|
stop)
|
||
|
echo "Stopping proxies"
|
||
|
start-stop-daemon --stop --pidfile $PIDFILE
|
||
|
rm -f $STATFILE
|
||
|
sleep 10
|
||
|
|
||
|
echo "Stopping interface"
|
||
|
for i in {2..249}
|
||
|
do
|
||
|
ip addr del $ELPROXNET.$i/32 dev $ELPROXIF 2>/dev/null
|
||
|
done
|
||
|
|
||
|
ifconfig $ELPROXIF down
|
||
|
;;
|
||
|
|
||
|
restart)
|
||
|
$0 stop; sleep 2; $0 start
|
||
|
;;
|
||
|
|
||
|
reload)
|
||
|
echo "Reloading proxies"
|
||
|
killall -9 $DAEMON
|
||
|
rm -f $STATFILE $PIDFILE
|
||
|
sleep 2
|
||
|
start-stop-daemon --start --pidfile $PIDFILE --make-pidfile --chuid $RUNASUSER --startas $DAEMON -- $CONFIG >>$ERRLOG 2>&1
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo "Usage: $0 {start|stop}"
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit 0
|