Re: loopback

Ian Eiloart <[email protected]> Tue, 03 Oct 2006 17:09:18 +0100
Newsgroups gmane.comp.apache.mod-wackamole.general
Message-ID <[email protected]>
--==========AB112C23B744A28A7929==========
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline



--On 28 September 2006 15:07:54 +0100 Ian Eiloart <[email protected]> wrote:

>  What I'm planning on doing is writing a wrapper script that will wait
> until an interface other than lo0 is available, then exec wackamole.

And, here it is - attached. Also attached is my launchd plist which calls 
the script on startup. launchd will restart the script process if it quits 
for any reason, so the script uses 'exec' which ensures that wackamole 
replaces the script in the same process - so launchd is now monitoring the 
wackamole process.

The scripts assume that the wackamole config is at 
/opt/local/etc/wackamole.conf, and the executable at 
/opt/local/sbin/wackamole. It's also assumed that your primary IP address 
is on en0 - but this can be easily modified.




-- 
Ian Eiloart
IT Services, University of Sussex
--==========AB112C23B744A28A7929==========
Content-Type: text/plain; charset=utf-8; name="startup.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="startup.sh"; size=792

#!/bin/bash
### waits (up to <timeout> seconds) for <interface> to come up
### then execs <command> in the same process
# timeout in seconds
timeout=3D30
# initialise counter
count=3D0
# which interface do you want to see?
interface=3Den0
# what's the command you want to run
command=3D'/opt/local/sbin/wackamole'
arguments=3D'-c /opt/local/etc/wackamole.conf -d'
# paths
ifconfig=3D/sbin/ifconfig
awk=3D/usr/bin/awk
grep=3D/usr/bin/grep
sleep=3D/bin/sleep
while [ $count  -lt $timeout  ];=20
do	
	if [ `$ifconfig -ua  inet | $awk ' { print $1 } ' | $grep $interface ` ] ; =
then
		if [ -x $command ] ; then
			exec $command $arguments
		else
			echo error $command not executable
		fi
		exit 1
	fi
	# increment counter
	count=3D$((++count ))
	# wait a second
	$sleep 1

done=20
echo $interface did not come up
exit 1

--==========AB112C23B744A28A7929==========
Content-Type: text/plain; charset=us-ascii; name="org.wackamole"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="org.wackamole"; size=610

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Debug</key>
        <true/>
        <key>Label</key>
        <string>org.wackamole</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
                <string>/opt/local/etc/wackamole/startup.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>Wackamole Daemon</string>
</dict>
</plist>

--==========AB112C23B744A28A7929==========
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
wackamole-users mailing list
[email protected]
http://lists.backhand.org/mailman/listinfo/wackamole-users

--==========AB112C23B744A28A7929==========--