Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Jan 31, 2013, 07:53 AM   #1
ACagliano
macrumors newbie
 
Join Date: May 2012
Creating a Launch Deamon for Portsentry

I have a program called portsentry that can be run under OS X using the following command line commands:

/opt/local/libexec/portsentry.sh -tcp
/opt/local/libexec/portsentry.sh -udp

So, instead of doing this every time I log in, I decided to create a script. However, when I launch the deamon, then do "ps aux | grep portsentry", it shows nothing running. What am I doing wrong in this script? I'm assuming I'm making a mistake with the plist file.

Code:
#!/bin/bash
# Mac OS X portsentry installation script
#
#
echo
echo This script will enable portsentry
echo and create a plist file to start up
echo the portsentry daemon at startup.
echo 
echo Press enter to continue...


# Set permissions
chown root:admin /opt/local/libexec/portsentry.sh
chmod 544 /opt/local/libexec/portsentry.sh

# Set up the plist file finally
echo "Setting up plist file at Library/LaunchDaemons/com.apple.portsentry.plist"

if ! touch /Library/LaunchDaemons/com.apple.portsentry.plist ; then
    echo Cannot touch the Library/LaunchDaemons/com.apple.portsentry.plist file.
    echo Exiting due to the previous error.
    exit
fi

echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0 //EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "<plist version=\"1.0\">" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "<dict>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <key>Label</key>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <string>com.apple.portsentry</string>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <key>ProgramArguments</key>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <array>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "        <string>/opt/local/libexec/portsentry.sh -tcp</string>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "        <string>/opt/local/libexec/portsentry.sh -udp</string>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    </array>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <key>RunAtLoad</key>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "    <true/>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "</dict>" >> /Library/LaunchDaemons/com.apple.portsentry.plist
echo -e "</plist>" >> /Library/LaunchDaemons/com.apple.portsentry.plist

chown root:admin /Library/LaunchDaemons/com.apple.portsentry.plist

echo "Complete."
echo
echo "Starting portsentry..."
launchctl load /Library/LaunchDaemons/com.apple.portsentry.plist
echo "Portsentry now active and running:"
ps aux | grep portsentry

echo
echo Done.
ACagliano is offline   0 Reply With Quote

 
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
PortSentry 2.0 ACagliano Mac Applications and Mac App Store 2 May 5, 2013 12:05 PM
iPad Mini Launch Attracting Shorter Lines on Launch Day MacRumors MacRumors.com News Discussion 244 Nov 4, 2012 12:15 AM
program - like deamon do something interval mehdies Mac Programming 1 Oct 3, 2012 02:41 PM
An odd connection between color and 4 launch/5 launch thadoggfather iPhone 0 Sep 26, 2012 11:43 PM

Forum Jump

All times are GMT -5. The time now is 05:37 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC