Problem solved, with help from a friend. Successfully bounced ideas off each other and came up with this:

Code:
#!/bin/bash

################################################################################
#
#  Script to be cronned every five minutes or so by a computer on a UPS that
#  needs to power on asap after power is restored after the UPS has ran out
#  of power and the computer has shut down
#
################################################################################

delay=30

# initial delay (in minutes)  before trying to start computer.  you want this to
# be longer than you know your UPS can run with the computer off because you
# don't want it to try to start the computer up right as the UPS is about to die

interval=60

# interval (in minutes) between events.  the lower the interval, the sooner it
# will turn on after power is restored.

ecount=12

# number of events.  the more events, the longer this script will take to run,
# but the longer the period of time it will continue to try to power back on.
# pmset appears to have  no limit to the number of scheduled events.

################################################################################

# delete all existing scheduled events.  takes 1/2 sec or so per event.  there is no "clear all" command.
pmset -g sched | grep "poweron" | while read n ; do pmset schedule cancel poweron "${n#* at }" ; done

# set power-on events
for ((e=0;e<ecount;e++)) ; do
  pmset schedule poweron "$(date -j -f "%s" $(($(date "+%s")+60*delay+60*interval*e)) "+%m/%d/%y %H:%M:%S"))"
done

pmset -g sched > /var/root/wakestick_updated


The idea is it is cronned every 5 minutes and updates the scheduled power on times, so no need to do anything when we drop over to ups power. So I have my ups set to orderly shutdown at 10 min power left. And I have the delay set to 30, so it will try to turn itself back on again 20 minutes after it shuts off. Ideally I want the UPS to have ran out of battery at that point, so there's no risk of it trying to power on when the ups has very little power left. (and lose power during startup)

If power isn't back yet, it will try again in an hour, and another from then for up to half a day. That should be enough.

Requires 10.5 or later due to the -j flag in the date command.


I work for the Department of Redundancy Department