Re: A few pointers about launchd and daemondo

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: A few pointers about launchd and daemondo

by Panagiotis Atmatzidis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
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."

_______________________________________________
launchd-dev mailing list
launchd-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev