• attachment:apache2_configure.py of ApplicationsPlatform/Clients/Web

Attachment 'apache2_configure.py'

Download

   1 import os
   2 import sys
   3 import yaml
   4 
   5 if os.geteuid() != 0:
   6     print "Script must be run as root. Use sudo."
   7     sys.exit()
   8 
   9 try:
  10     with open("/etc/ros/app_platform/apache2_config.yaml", "r") as f:
  11         y = yaml.load(f.read())
  12         y = y or {} 
  13 except:
  14     print "No file /etc/ros/app_platform/apache2_config.yaml"
  15 
  16 try:         
  17     with open("/etc/apache2/httpd.conf", "a") as g:
  18         for key,value in y["aliases"].iteritems():
  19             g.write('DocumentRoot "/var/www"\n')
  20             g.write('Alias /' + key + ' ' + value + '\n')
  21             g.write("        </Directory> " + value + '\n') 
  22             g.write('''                Options Indexes FollowSymLinks MultiViews
  23                 AllowOverride None
  24                 Order allow,deny
  25                 allow from all
  26         </Directory>  
  27             \n''')
  28 except Exception, e:
  29     print e
  30     print "File /etc/apache2/httpd.conf is unable to be found/edited. You must configure your installation manually."        

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-04-21 00:12:35, 1.0 KB) [[attachment:apache2_configure.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.