summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-05 01:17:54 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-05 01:17:54 -0300
commit9ae52873d39f8eccf023349bc6dd2f7031a15c04 (patch)
tree09e96f7b9213683ea39aa7a9b29dc643aefd95cd
parent3f127172f5f4c19b99ad33cf66030df92139df7d (diff)
downloadupdates-9ae52873d39f8eccf023349bc6dd2f7031a15c04.tar.gz
updates-9ae52873d39f8eccf023349bc6dd2f7031a15c04.tar.bz2
updates-9ae52873d39f8eccf023349bc6dd2f7031a15c04.tar.xz
updates-9ae52873d39f8eccf023349bc6dd2f7031a15c04.zip
Necessary changes for the all-in-one zip file to work
-rwxr-xr-xcomp.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/comp.py b/comp.py
index d69652a..9b9d66d 100755
--- a/comp.py
+++ b/comp.py
@@ -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.")