How to add startup program using Terminal?
LaunchDaemons – Run at Boot
LaunchAgents – Run at Login
So... you need a daemon
suggest you to cat /System/Library/LaunchDaemons/com.apple.pfctl.plist
or any other in the same dir and use it as reference.
Just remove unnecessary. It will be something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>shell.sh</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/shell.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
save the file in the same dir, but named shell.sh.plist
and run
sudo launchctl load /System/Library/LaunchDaemons/shell.sh.plist
to remove script from the load list:
sudo launchctl unload /System/Library/LaunchDaemons/shell.sh.plist
this is not linux so things are done Mac way.
man launchd
& man launchd.plist
will provide all needed info
OR
you can use an approach described here
Creating .plist
just once and pointing it to your startup script which in turn will start anything you add there without need to write new .plist
every time you want to start something new.