/ freenet-start.applescript
freenet-start.applescript
 1  on clicked theObject
 2  	-- Read in the preferences
 3  	set theLocation to POSIX path of (call method "defaultObjectForKey:" with parameter "location")
 4  	
 5  	try
 6  		set theResult to do shell script "ps -ax | grep  freenet" as string
 7  		if theResult contains "freenet.node.main" then
 8  			try
 9  				-- enclosed in a try otherwise when dialog is canceled we get the gadzooks message
10  				display dialog "Error: Freenet is currently running."
11  				tell progress indicator "progress" of window "main" to start
12  			end try
13  		else
14  			try
15  				do shell script "cd " & theLocation & ";sh start-freenet.sh > /dev/null 2>&1 &"
16  				tell progress indicator "progress" of window "main" to start
17  			on error
18  				display dialog "Error: Unable to execute start-freenet.sh. Might it be missing?"
19  			end try
20  		end if
21  	on error
22  		display dialog "Gadzooks! I couldn't find 'ps'!!!"
23  	end try
24  end clicked
25