[launchd-dev] A few pointers about launchd and daemondo

Panagiotis Atmatzidis atma at convalesco.org
Sat Oct 31 04:51:42 PDT 2009


Hello,

I solved both issues adjusting the wrapper accordingly. Should I throw  
a ticket for this wrapper for this to be added on macports? I don't  
know how to edit the port though...

# openvpn configuration file
#!/bin/sh

. /etc/rc.common

load() {
		if [ -d /System/Library/Extensions/tun.kext ]; then
			kextload -q /System/Library/Extensions/tun.kext;
		else
			echo "tun.kext not found in /System/Library/Extensions/"
		fi
	}

StartService() {
		#
		# Use the "ipconfig waitall" command to wait for all the
		# interfaces to come up:
		#
		ipconfig waitall
		
		load; # first load the module
		if [[ $( kextstat -l | grep -q 'tun' )$? == 0 ]]; then
                 /opt/local/sbin/openvpn2 --config /opt/local/etc/ovpn/ 
server.conf --writepid /opt/local/etc/ovpn/ovpn.pid --daemon OpenVPN2
				/usr/bin/logger "OpenVPN is loaded"
         else
				/usr/bin/logger "tun extensions is not loaded."
		fi
}

StopService() {
	pid=`cat /opt/local/etc/ovpn/ovpn.pid`
	if [ $? -eq 0 ]; then
	    kill $pid
	fi


	if [[ $( kextstat -l | grep -q 'tun' )$? == 0 ]]; then
   		kextunload /System/Library/Extensions/tun.kext
	
		if [[ $( kextstat -l | grep -q 'tun' )$? == 0 ]]; then
			/usr/bin/logger "The tun module is unloaded successfully"
		else
			/usr/bin/logger "There was a problem. I was not able to unload tun  
module!!!"
   		fi
	fi


}

RestartService() {
   StopService "$@"
   StartService "$@"
}

RunService "$1"





Panagiotis (atmosx) Atmatzidis

email:	atma at convalesco.org
URL:	http://www.convalesco.org
GnuPG key id: 0xFC4E8BB4
--
The wise man said: "Never argue with an idiot. They bring you down to  
their level and beat you with experience."



More information about the launchd-dev mailing list