diff options
-rwxr-xr-x | comp.py | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -18,11 +18,21 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ######################################################################################## # This builds live/ folder for Update Server -import subprocess, os, uuid, traceback +import subprocess, os, uuid, traceback, hashlib, copy PATH="/var/www/html/assets" +def md5sum(f): + md5=hashlib.md5() + fp=open(f, "rb") + ct=fp.read() + md5.update(ct) + rt=copy.copy(md5.hexdigest()) + fp.close() + del ct + return rt + # Delete previous deployment -subprocess.call("rm --recursive %s/*" % PATH, shell=True) +subprocess.call("rm -rf %s/*" % PATH, shell=True) # Go through every file in raw and give them a hash @@ -58,13 +68,15 @@ for path, subdir, files in os.walk("raw/"): # Create blank index page to disable dir listing subprocess.call("touch %s/index.html" % PATH, shell=True) -# TODO: zip everything and provide an all-in-one download? +# Zip everything and provide an all-in-one download fn="%s/%s.zip" % (PATH, uuid.uuid4().hex) subprocess.call('cd %s; find . -printf "%%P\n" | zip -X -9 -@ %s' % (PATH, fn), shell=True) +mdi = md5sum(fn) +subprocess.call("echo \"%s#%s\" > %s/fetch.txt" % (fn.replace(PATH, ""), mdi, PATH), shell=True) # Correct permissions -subprocess.call("chown -R www-data:www-data %s/*" % PATH, shell=True) -subprocess.call("chmod --recursive o-rwx %s/*" % PATH, shell=True) +#subprocess.call("chown -R www-data:www-data %s/*" % PATH, shell=True) +subprocess.call("chmod --recursive 444 %s/*" % PATH, shell=True) print("FILENAME: %s" % fn) print("Register it in \"token\" value of server config to serve all-in-one downloads.") |