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

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 22, 2008, 03:17 PM   #1
GirthP
macrumors regular
 
Join Date: Oct 2007
Loading tuncfg and hamachi at startup... I did it!!

Finally.

If any of the specifics are wrong, please reply, I'm a beginner, and love to learn.

I thought I'd post this thread in case anyone else ever needs this info, and was starting at the beginning like me with launchd and bash scripting.

I wanted to startup hamachi on leopard automatically at login or boot.

For those that don't know, leopard doesn't have a functioning GUI yet for hamachi. One must sudo tuncfg, and then start hamachi manually at the command line every time you want to run it.

If you don't know what hamachi or tuncfg is, that's outside of the scope of this post, but I'll reply to any questions

Starting at the ending.
1) tuncfg is called from a bash script at startup

2) hamachi start, hamachi login, and hamachi go-online networkname are called at login

I wrote two .plist files and two bash scripts to accomplish this.

The files

This is the bash script that runs tuncfg. It lives in my computer at /Library/BootScripts.
I have the script wait 30 seconds before it runs, to wait for the tun kernel extensions to load (meaningless details that were not meaningless when it wouldn't work!! )
Code:
#!/bin/bash

sleep 30s
tuncfg
Here is the script that loads hamachi. It lives in my computer at /Library/BootScripts.
Code:
#!/bin/bash

hamachi start
hamachi login
hamachi go-online YourNetworkNameHere
Both of those scripts have to be chmod 770 and chown root:wheel I believe.

The .plist files

The first launchd .plist file goes in /Library/LaunchDaemons. It loads tuncfg at startup.

Here it is...
Code:
<?xml version="1.0" encoding="UTF-8"?>
	<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
		"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
	<plist version="1.0">
	<dict>
		<key>Label</key>
		<string>com.boothamachi.launchd.boothamachi</string>
		
		<key>KeepAlive</key>
		<false/>
	
		<key>ProgramArguments</key>
		<array>
			<string>/Library/BootScripts/boothamachi.sh</string>
			<string>run</string>
		</array>

		<key>RunAtLoad</key>
		<true/>
	</dict>
	</plist>

And the second .plist file lives in /Library/LauchAgents. It runs at login.

Code:
<?xml version="1.0" encoding="UTF-8"?>
	<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
		"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
	<plist version="1.0">
	<dict>
		<key>Label</key>
		<string>com.loadhamachi.launchd.loadhamachi</string>
		
		<key>KeepAlive</key>
		<false/>
	
		<key>ProgramArguments</key>
		<array>
			<string>/Library/BootScripts/loadhamachi.sh</string>
			<string>run</string>
		</array>

		<key>RunAtLoad</key>
		<true/>
	</dict>
	</plist>
Okay.

That is all the info.

I learned about bash scripting, chmod, chown, launchd.plist, launchctl...

This took me a few days of not getting it before it came together.

Things to remember... change the ownership of the .plist files and scripts. Look at the Console.app readout if things aren't working. It's worth the time to learn what it is saying...

Thanks for stopping by!
__________________
iPhone 16GB 3G
Home: 2.2 MBP 4GB 320GB WD Scorpio

Work: 8 core 2.8 MP 8GB w/ 2 24" Dell UltraSharps
GirthP is offline   0 Reply With Quote
Old Mar 22, 2008, 05:37 PM   #2
Ben8472
macrumors member
 
Join Date: Mar 2008
great thing only it doesn't work for me

do i have to do anything with the plist files?
What exact names do i need to name all the files?


I will try using an automator script as a startup item and see if that works
Ben8472 is offline   0 Reply With Quote
Old Mar 22, 2008, 07:36 PM   #3
GirthP
Thread Starter
macrumors regular
 
Join Date: Oct 2007
what do you mean "do" with the .plist files?

I slaved over them for a day or two , if that's what you mean... you can check and see what is going on in the console readout.

If you can tell me what the console is saying, I can probably help you.

I know it's not easy, and I could have missed a step or two... so feel free to ask, or chat me up.
__________________
iPhone 16GB 3G
Home: 2.2 MBP 4GB 320GB WD Scorpio

Work: 8 core 2.8 MP 8GB w/ 2 24" Dell UltraSharps
GirthP is offline   0 Reply With Quote
Old Mar 23, 2008, 11:31 AM   #4
Ben8472
macrumors member
 
Join Date: Mar 2008
ended up creating an applescript that starts when my user logs on and executes the .sh file to start hamachi, works for me, so thanks for the .sh examples
Ben8472 is offline   0 Reply With Quote
Old Jul 10, 2008, 12:22 AM   #5
krymzon40
macrumors newbie
 
Join Date: Jul 2008
Kinda confused

Ok, i'm very new to this so let me see if i got it....
The first 2 scripts i can create by putting them in a plaintext file with the ending .sh and they go in /Library/Bootscripts
And the 2 plist files i can make the same way with a .plist ending and they go in /Library/LauchAgents and /Library/LauchDaemons
How do i change the permissions? Would get info and changing it there work? or do i have to use terminal? If i do, then how do i do it?

And finally after i do that it should work?
krymzon40 is offline   0 Reply With Quote
Old Jul 10, 2008, 12:25 AM   #6
krymzon40
macrumors newbie
 
Join Date: Jul 2008
Quote:
Originally Posted by Ben8472 View Post
ended up creating an applescript that starts when my user logs on and executes the .sh file to start hamachi, works for me, so thanks for the .sh examples
Oh and if that's easier could you either send it or tell me how?
krymzon40 is offline   0 Reply With Quote
Old Jul 17, 2008, 04:17 PM   #7
Ben8472
macrumors member
 
Join Date: Mar 2008
i will pack up a zipped pack with a manual as soon as i have some more time on my hands, i promise!
Ben8472 is offline   0 Reply With Quote

Reply
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
Weird startup/loading folder files problem with new rMBP... Texxy MacBook Pro 8 Nov 6, 2013 01:09 AM
Minecraft- LogMeIn Hamachi for PPC? keremtezcan PowerPC Macs 1 Jun 23, 2013 06:39 AM
"Other" System Preferences no longer loading on startup/login? jamie.shaw OS X 10.8 Mountain Lion 1 Dec 28, 2012 12:47 PM
Loading bar on startup reinventinglove MacBook Pro 3 Dec 16, 2012 10:30 AM
LogMeIn Hamachi Question macuser1232 Community Discussion 1 Oct 8, 2012 01:36 PM

Forum Jump

All times are GMT -5. The time now is 11:39 PM.

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

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