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!! )
Here is the script that loads hamachi. It lives in my computer at /Library/BootScripts.
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...
And the second .plist file lives in /Library/LauchAgents. It runs at login.
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!
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 [I]YourNetworkNameHere[/I]
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!