summaryrefslogtreecommitdiff
path: root/backend/update.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/update.py')
-rwxr-xr-xbackend/update.py148
1 files changed, 50 insertions, 98 deletions
diff --git a/backend/update.py b/backend/update.py
index ebf82bf..47b05c4 100755
--- a/backend/update.py
+++ b/backend/update.py
@@ -1,128 +1,80 @@
#!/usr/bin/env python2
-import os
-import sys
+import resilient
+import resilient.freenet
-############### Enumerate dependencies
+##################### Instantiate remotes
-found_git = (os.system("git status --porcelain") == 0)
+git_repos = [
+ resilient.git('git://standingwithresilience.branchable.com/'),
+ resilient.git('fairlystable-guest:/srv/git/standingwithresilience')
+]
-if not found_git:
- print("ERROR: git not found")
- exit(1)
+if resilient.freenet.gitocalypse.found and resilient.freenet.running:
+ git_repos.extend([
+ #### public freenet ####
+ resilient.freenet.gitocalypse('freenet://USK@hCLgfaINNSNAl4do-PapEincQP5Lxa72d8mFrzHqzqU,jjuBPGO~oCByVoZ5f4Bny0Gp-l3kuDOtf3m-QBT4ekA,AQACAAE/Standing%20With%20Resilience%20Public.git.R1/0', 'freenet://USK@AKL0griFs7T25yw6-JR3Wk7vocvNBelOLg3RwtIL6aTp,jjuBPGO~oCByVoZ5f4Bny0Gp-l3kuDOtf3m-QBT4ekA,AQECAAE/Standing%20With%20Resilience%20Public.git.R1/0'),
+ #### private freenet ####
+ resilient.freenet.gitocalypse('freenet://USK@PSY0YngeDtGbj60hjEoilQiY9oKzVrptRC0rG4BEVPg,e6ZEjT4KvbsltPBJOeKNpIdty2oGzbLCdk4fsDA5Vdk,AQACAAE/Standing%20With%20Resilience.git.R1/0')
+ ])
-found_ikiwiki = (os.system("ikiwiki --version") == 0)
-found_gitocalypse = (os.system("git-remote-freenet") == 256)
-found_freesitemgr = (os.system("freesitemgr --version") == 0)
-found_zeronet = 'ZERONETDIR' in os.environ
-if found_zeronet:
- zn_datadir = os.path.join(os.environ['ZERONETDIR'], 'ZeroNet/data')
- zn_script = os.path.join(os.environ['ZERONETDIR'], 'ZeroNet.sh')
- found_zeronet = (os.system("'%s' --version" % zn_script) == 0)
-
-if not found_ikiwiki:
- print("WARNING: ikiwiki not found, pages will not be built")
-if not found_gitocalypse:
- print("WARNING: gitocalypse not found, changes won't be synced with freenet")
-if not found_freesitemgr:
- print("WARNING: freesitemgr/pyFreenet not found, public freesite won't be updated")
-if not found_zeronet:
- print("WARNING: ZeroNet not found in ZERONETDIR, public zeronet site won't be updated")
-
-if not (found_ikiwiki or found_gitocalypse or found_freesitemgr):
- print("Changes will still be propagated if branchable is working.")
+zeronet_urls = ['http://bit.no.com:43110']
+if resilient.zeronet.running:
+ zeronet_urls.append('http://127.0.0.1:43110')
+for host in zeronet_urls:
+ git_repos.extend([
+ #### public zeronet ####
+ resilient.git('%s/1GtQ8bkFkhYtKerSdXHKe1z4j9VTmFR5d4/.git' % host),
+ #### private zeronet ####
+ resilient.git('%s/1L363bqJnCG63SnV83kfV7izZXbmentctD/.git' % host)
+ ])
####################### Download from all
-print(":: Pulling from simple repos ...")
-os.environ["GIT_SSH_COMMAND"] = "ssh -F backend/auth/ssh-config"
-
-status = 0
-status += os.system("git pull git://standingwithresilience.branchable.com/ master")
-
-if status != 0:
- print("WARNING: failed to pull changes from branchable")
- #exit(status)
-
-status += os.system("git pull fairlystable-guest:/srv/git/standingwithresilience master")
+print(":: Pulling from git repos ...")
-if status != 0:
- print("WARNING: failed to pull changes from fairlystable")
- #exit(status)
+for repo in git_repos:
+ repo.pull()
-del os.environ["GIT_SSH_COMMAND"]
+########################### Upload to all
+print(":: Pushing to git repos ...")
-# Pull from zeronet repos
-print(":: Pulling from zeronet repos ...")
-# public zeronet
-os.system("git pull http://127.0.0.1:43110/1GtQ8bkFkhYtKerSdXHKe1z4j9VTmFR5d4/.git master")
-# private zeronet
-os.system("git pull http://127.0.0.1:43110/1L363bqJnCG63SnV83kfV7izZXbmentctD/.git master")
+for repo in git_repos:
+ repo.push()
-# Pull from freenet repos
-if found_gitocalypse:
- print(":: Pulling from freenet repos ...")
- # public freenet
- os.system("git pull freenet://USK@hCLgfaINNSNAl4do-PapEincQP5Lxa72d8mFrzHqzqU,jjuBPGO~oCByVoZ5f4Bny0Gp-l3kuDOtf3m-QBT4ekA,AQACAAE/Standing%20With%20Resilience%20Public.git.R1/0 master")
- # private freenet
- os.system("git pull freenet://USK@PSY0YngeDtGbj60hjEoilQiY9oKzVrptRC0rG4BEVPg,e6ZEjT4KvbsltPBJOeKNpIdty2oGzbLCdk4fsDA5Vdk,AQACAAE/Standing%20With%20Resilience.git.R1/0 master")
+############################## Build wiki
+if not resilient.ikiwiki.found:
+ print (":: Not building wiki; missing ikiwiki")
+ exit(0)
+print (":: Building wiki ...")
-######################### Upload to all
-
-print(":: Pushing to simple repos ...")
-os.environ["GIT_SSH_COMMAND"] = "ssh -F backend/auth/ssh-config"
-
-status += os.system("git push git://standingwithresilience.branchable.com/")
-status += os.system("git push fairlystable-guest:/srv/git/standingwithresilience")
-
-del os.environ["GIT_SSH_COMMAND"]
-
+if not resilient.ikiwiki().push():
+ print (":: Exiting due to failure")
+ exit(-1)
-# Push to freenet repos
-if found_gitocalypse:
- print (":: Pushing to freenet repos ...")
- # public freenet
- os.system("git push freenet://USK@AKL0griFs7T25yw6-JR3Wk7vocvNBelOLg3RwtIL6aTp,jjuBPGO~oCByVoZ5f4Bny0Gp-l3kuDOtf3m-QBT4ekA,AQECAAE/Standing%20With%20Resilience%20Public.git.R1/0")
+####################### Instantiate hosts
+hosts = []
-# Build wiki
+if resilient.zeronet.found:
+ hosts.append(resilient.zeronet('1GtQ8bkFkhYtKerSdXHKe1z4j9VTmFR5d4', '5JzZACCELsT4bx66qmV9JDaWhEQ6Sx6j7LzeucsxJGA9H7nuoRr'))
-if status != 0:
- print (":: Exiting due to failure")
- exit(status)
+if resilient.freenet.freesitemgr.found and resilient.freenet.running:
+ hosts.append(resilient.freenet.freesitemgr()) # keys for freesitemgr are in auth/freesitemgr
-if not found_ikiwiki:
- print (":: Not building wiki; missing ikiwiki")
- exit(0)
+########################### Upload to all
-print (":: Building wiki ...")
+print (":: Publishing site ...")
-status += os.system("ikiwiki --wikiname 'A Wiki for Targeted Individuals' --rebuild ../wiki ../html")
+for host in hosts:
+ host.push()
-if status != 0:
- print (":: Exiting due to failure")
- exit(status)
-
-if found_zeronet:
- os.system('git update-server-info')
- print (":: Publishing ZeroNet site ...")
- zn_datadir = os.path.join(zn_datadir, '1GtQ8bkFkhYtKerSdXHKe1z4j9VTmFR5d4')
- os.system('cp -r ../html/. %s/.' % zn_datadir)
- os.system('mkdir -p %s/.git' % zn_datadir)
- for file in ('objects', 'refs', 'HEAD', 'info', 'packed-refs'):
- os.system('cp -a ../.git/%s %s/.git' % (file, zn_datadir))
- os.system('%s siteSign 1GtQ8bkFkhYtKerSdXHKe1z4j9VTmFR5d4 5JzZACCELsT4bx66qmV9JDaWhEQ6Sx6j7LzeucsxJGA9H7nuoRr' % zn_script)
-
-if found_freesitemgr:
- print (":: Publishing freesite ...")
- status += os.system("freesitemgr -c freesitemgr -v -l freesitemgr.log -r 1 update")
+#########################################
print "Done."
-
-exit(status)