The goal here is to have an OSX pagekite backend run automatically when the system starts up. Inspired by the DebianPackage, these instruction put pagekite.py in /usr/bin and the config file at /etc/pagekite/pagekite.rc.
Download pagekite.py. You'll need to change the permissions to make it system runnable, and then put it in /usr/bin.
wget --no-check-certificate http://pagekite.net/pk/pagekite.py
chmod +x pagekite.py
sudo chown root:wheel pagekite.py
mv pagekite.py /usr/bin/pagekite.py
Download a sample pagekite.rc config file, or configure one however you like - nothing special should need to be changed for OSX.
mkdir /etc/pagekite/
mv .pagekite.rc /etc/pagekite/pagekite.rc
Now add pagekite.py as a launchctl service, pointing it to the options file:
sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc
Now that it's installed with launchctl, pagekite.py should start whenever the system boots up, and even if pagekite.py crashes it should be restarted. These commands may be helpful:
sudo launchctl start pagekite
sudo launchctl stop pagekite
sudo launchctl remove pagekite
[ Back to How-Tos ]
Comments
sudo launchtl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc
Should be:
sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc
I tried to install pagekite as a service, the service works after executing the above command "sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc" but doesn't restart after a reboot.
Do you have an idea of what I am missing ?
Cheers.
launchctl with argument "submit" is not creating anything which survives a reboot.
"submit" by default also will use the keep alive functionality. So the mentioned "launchctl stop" will in effect not stop the demon but kinda restart it as launchd will restart the process if it is being stopped.
To stop the daemon you need to use "remove" but this will not left anything over to "start" it again.
To really create a daemon which survives a reboot you have to create a plist file in /Library/LaunchDaemons which will add this daemon to the global daemons which are run at boot time by launchd.
Meanwhile I am working on a Blog entry with the detailed instructions. You may consider updating the wiki to something more useful!
<?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>pagekite.service</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/pagekite.py</string>
<string>--optfile=/etc/pagekite/pagekite.rc</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Then, to install the service, run:
sudo launchctl load /Library/LaunchDaemons/pagekite.service.plist