X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=cron.d%2Fsyncadmins.py;fp=cron.d%2Fsyncadmins.py;h=74904968cd9609d9fab7b8e42bf89c6b911fc491;hb=279af3a93e11a4352438887d4593e19d63d622b3;hp=0000000000000000000000000000000000000000;hpb=296e976b7b80f9d20a5ecedb5810cdeb84541944;p=plcrt.git diff --git a/cron.d/syncadmins.py b/cron.d/syncadmins.py new file mode 100755 index 0000000..7490496 --- /dev/null +++ b/cron.d/syncadmins.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import os +import sys + +#NOTE: I'm so sorry for this. +try: + # if this file deos not exist, then we will jump to the exception and use + # the local PLCSH without passing any additional arguments. + os.stat("/etc/planetlab/master.py") + sys.path.append("/etc/planetlab") + import master + + # Use the values given to us in the /etc/planetlab/master.py file taken from + # the master PLC and use them to construct the proper arguments to plcsh so + # that we can get a user list from managing, CoPLC + user=master.PLC_ROOT_USER + passwd=master.PLC_ROOT_PASSWORD + url = "https://" + master.PLC_API_HOST + ":" \ + + master.PLC_API_PORT + master.PLC_API_PATH + + plcsh_args = "--user=%s --password=%s --url=%s %s" % (user, passwd, url, " ".join(sys.argv[1:])) +except: + plcsh_args = "%s" % " ".join(sys.argv[1:]) + +dir = "/usr/share/plcrt" +os.system("chmod 755 %s/getpersons.py" % dir) +os.system("%s/getpersons.py %s -- admin | %s/adduserstort.pl priv -" % ( dir, plcsh_args, dir) )