#!/bin/bash # # linc Startup script for the Linc client # # Author: Philip Tellis # # chkconfig: 2345 20 80 # description: linc is a free multiplatform client for Cyberoam and \ # 24online. # processname: linc # pidfile: /var/run/linc.pid # config: /etc/lincrc # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 1 servaddr=`awk '/srvaddr/ {print $3}' /etc/lincrc` servport=`awk '/srvport/ {print $3}' /etc/lincrc` if ! /bin/ping -c 1 -w 3 $servaddr &>/dev/null ; then [ -x /usr/bin/logger ] && logger $"linc server not responding to ping" exit 1 fi # Path to the linc script linc=/usr/bin/linc prog=linc RETVAL=0 punch_firewall() { if ! ipchains -L input -n | grep -q "$servaddr.*$servport" ; then ipchains -I input -s $servaddr/32 $servport -d 0/0 -p udp -j ACCEPT [ -x /usr/bin/logger ] && logger $"punching linc server $servaddr:$servport through the firewall" fi } start() { echo -n $"Starting $prog: " punch_firewall daemon $linc RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/linc return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $prog -INT RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/linc /var/run/linc.pid } login() { if [ -e /var/lock/subsys/linc ]; then echo -n $"Logging in $prog: " killproc $prog -USR1 RETVAL=$? echo else start fi } logout() { if [ -e /var/lock/subsys/linc ]; then echo -n $"Logging out $prog: " killproc $prog -USR2 RETVAL=$? echo fi } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $linc RETVAL=$? ;; restart) stop start ;; logout) logout ;; login) login ;; *) echo $"Usage: $prog {start|stop|restart|status|help|login|logout}" exit 1 esac exit $RETVAL