1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00
iiab/roles/kiwix/templates/iiab-make-apache-config.py
georgejhunt f319afa432 Test (#20)
* change apache_data to apache_user in all

* no libapach2 in centos. just php. no php-magick in centos

* remove redundant vars entries

* do not create apache user

* missed one pound sign

* soft code all references to apache_user

* centos requires older setuptools

* revert ansible_lsb.id in xsce.yml

* try getting recent pip

* move pip download to 2prep so that kalite success is not dependent on iiab coming first

* still need to replace setuptools in kalite

* add curl -- needed in debian

* massivly substitue iiab for xsce, and rename files

* completed runansible

* centos fixes,install  pip

* appliance means no iptables rules

* change to earlier version of setuptools for centos

* delete file duplicate, hopefully unnecessary. generate the offline docs

* wiki docs errors

* create the admin group -- deleted earlier

* use the --yes option with pip uninstall

* base of repo moved from schoolserver to iiab, unleashkids.org->iiab.io

* network detection broken due to tupo
2017-06-09 16:25:56 -07:00

37 lines
970 B
Python
Executable file

#!/usr/bin/python
# write out proxy definitions for zim currently loaded
import os, sys, syslog
iiab_zim_path = "/library/zims"
kiwix_apache_config = "/etc/apache2/sites-available/kiwix.conf"
def main ():
content = iiab_zim_path + "/content/"
index = iiab_zim_path + "/index/"
# remove existing file
try:
os.remove(kiwix_apache_config)
except:
pass
with open(kiwix_apache_config, 'w') as fp:
fp.write("RewriteEngine on\n")
fp.write("ProxyPreserveHost on\n")
for filename in os.listdir(content):
zimpos = filename.find(".zim")
if zimpos != -1:
filename = filename[:zimpos]
fp.write("ProxyPass /%s/ http://localhost:3000/%s/\n" % (filename,filename))
fp.write("ProxyPassReverse /%s/ http://localhost:3000/%s/\n" % (filename,filename))
if __name__ == "__main__":
# Run the main routine
main()
# vim: tabstop=3 shiftwidth=3 expandtab softtabstop=3