Moved disco-ball to universe, added functions necessary for fetching, templating, and executing a given disco ball. Made all existing scripts aware of NOOP and how to change their DISCOROOT accordingly. Added skeleton restricted.d/* files for a semi-safe base system. Added disco-param that allows management of parameters on the client (currently isn't smart enough to manage them on the server, or per-module). Added client/bin/disco that actually allows the entire thing to come together and get executed. Still lots of bugs to work out.
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
DISCOROOT="/var/disco/testfs/real"
|
||||
if ("NOOP" in os.environ) and (os.environ["NOOP"] != ""):
|
||||
DISCOROOT="/var/disco/testfs/noop"
|
||||
|
||||
def file_is_text(fname):
|
||||
os.system("file %s > /tmp/%s.typeof" % (os.path.abspath("/var/disco/testfs/scratchfs/" + fname), os.getpid()))
|
||||
global DISCOROOT
|
||||
os.system("file %s > /tmp/%s.typeof" % (os.path.abspath(DISCOROOT + "/scratchfs/" + fname), os.getpid()))
|
||||
with open("/tmp/%s.typeof" % os.getpid(), "r") as ifile:
|
||||
line = ifile.readline()
|
||||
if "ASCII" in line:
|
||||
@@ -10,6 +15,7 @@ def file_is_text(fname):
|
||||
return False
|
||||
|
||||
def main(argc, argv):
|
||||
global DISCOROOT
|
||||
for line in sys.stdin.readlines():
|
||||
line = line.strip("\n")
|
||||
pid = os.getpid()
|
||||
@@ -18,13 +24,13 @@ def main(argc, argv):
|
||||
if file_is_text(fname):
|
||||
content = ""
|
||||
|
||||
with open(os.path.abspath("/var/disco/testfs/scratchfs/%s" % fname), "r") as ifile:
|
||||
with open(os.path.abspath(DISCOROOT + "/scratchfs/%s" % fname), "r") as ifile:
|
||||
content = "> " + "> ".join(ifile.readlines())
|
||||
line = line.replace("(CONTENT)", "\n%s" % (content))
|
||||
elif os.path.isdir("/var/disco/testfs/scratchfs/" + fname):
|
||||
elif os.path.isdir(DISCOROOT + "/scratchfs/" + fname):
|
||||
line = line.replace("(CONTENT)", "directory")
|
||||
else:
|
||||
os.system("md5sum /var/disco/testfs/scratchfs/%s > /tmp/%s" % (fname, pid))
|
||||
os.system("md5sum " + os.path.abspath(DISCOROOT + "/scratchfs/" + fname) + " > /tmp/%s" % (pid))
|
||||
content = ""
|
||||
with open("/tmp/%s" % (pid), "r") as ifile:
|
||||
content = ifile.readline().split(" ")[0]
|
||||
@@ -32,14 +38,14 @@ def main(argc, argv):
|
||||
line = line.strip("\n")
|
||||
if "(OLDMD5SUM)" in line:
|
||||
fname = line.split(" ")[3]
|
||||
os.system("md5sum /var/disco/testfs/rootfs/%s > /tmp/%s" % (fname, pid))
|
||||
os.system("md5sum " + os.path.abspath(DISCOROOT + "/rootfs/" + fname) + " > /tmp/%s" % (pid))
|
||||
content = ""
|
||||
with open("/tmp/%s" % (pid), "r") as ifile:
|
||||
content = ifile.readline().split(" ")[0]
|
||||
line = line.replace("(OLDMD5SUM)", content).strip("\n")
|
||||
if "(NEWMD5SUM)" in line:
|
||||
fname = line.split(" ")[3]
|
||||
os.system("md5sum /var/disco/testfs/scratchfs/%s > /tmp/%s" % (fname, pid))
|
||||
os.system("md5sum " + os.path.abspath(DISCOROOT + "/scratchfs/" + fname) + " > /tmp/%s" % (pid))
|
||||
content = ""
|
||||
with open("/tmp/%s" % (pid), "r") as ifile:
|
||||
content = ifile.readline().split(" ")[0]
|
||||
|
||||
Reference in New Issue
Block a user