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.
/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.