Then you can execute this action group eg with a schedule at eg 2am: your indigo server will gently shutdown (ie indigo will shutdown gracefully) and then reboot immediately
Use as you see fit.
Karl
ps this will also be part of the next utilities plug version
Code: Select all
# Karl Wachs June 9, 2024
# MIT license, use as you see fit, no warrenty what so ever
#
# this script will shutdown the indigo server and after xx secs, then reboot the mac
# set the wait time before rebot and the mac password
# set these parameters:
yourPassword = "xxxxx" # the mac user id password, needed to issue "sudo -S" command
waitBeforeReboot = 15 # this needs to be long enough to make sure indigo shuts down completely (just measure how long it takes for indigo to shutdown, add 3 secs to it)
import os, subprocess
# get indigo server proc pid
cmd = "ps -ef | grep 'MacOS/IndigoServer' | grep -v grep "
ret = str(subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0])
# py 3x/2x are diffirent:
if ret.find("b' ") > -1: # py3 binary return begins with a "b' "
pid = ret.split()[2]
else:
pid = ret.split()[1] # py2
# got all info
indigo.server.log( "terminating indigo server pocess: {} then rebooting after {} secs".format(ret, waitBeforeReboot))
# now executing
try:
pid = int(pid)
# create shell file that will do the job, will be deleted at reboot by system, so no password visible after reboot
f = open("/tmp/abc.sh","w")
cmd = "kill -15 {} ;/bin/sleep {} ;echo '{}' | /usr/bin/sudo -S /sbin/shutdown -r now &".format(pid, waitBeforeReboot, yourPassword) # path to sudo etc must be included, as terminal opened this way does not find it in PATH
f.write(cmd)
f.close()
# now executing stop indigo and the reboot
#indigo.server.log("shutting down now with: {}".format(cmd))# can enabled, but then password is visible in logfile
os.system("sh /tmp/abc.sh")
return
except Exception as e:
indigo.server.log( "{}".format(e))