Follow this:
-
start
Automator.app -
select
Application -
click
Show libraryin the toolbar (if hidden) -
add
Run shell script(from theActions/Utilities) -
copy & paste your script into the window
-
test it
-
save somewhere (for example you can make an
Applicationsfolder in your HOME, you will get anyour_name.app) -
go to
System Preferences->Users & Groups->Login items(orSystem Preferences->Accounts->Login items/ depending of your MacOS version) -
add this app
-
test & done 😉
EDIT:
I’ve recently earned a “Good answer” badge for this answer. While my solution is simple and working, the cleanest way to run any program or shell script at login time is described in @trisweb’s answer, unless, you want interactivity.
With automator solution you can do things like next:

so, asking to run a script or quit the app, asking passwords, running other automator workflows at login time, conditionally run applications at login time and so on…