Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Abente <martin.abente.lahaye@gmail.com>2011-02-09 21:06:19 (GMT)
committer Martin Abente <martin.abente.lahaye@gmail.com>2011-02-09 21:06:19 (GMT)
commit3b2b07671ab97541cb7c427ef9142e672b53889c (patch)
treeaf615a63e4d876f10b85838f910bff2446c15365
parent913cfc4e198b31ba806e9d8c906a0c9bff05d098 (diff)
setup script
-rwxr-xr-xsetup.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..ea34642
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2011, Martin Abente
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+
+import os
+import sys
+from urlparse import urlparse
+from ConfigParser import ConfigParser
+
+config = ConfigParser()
+script_path = os.path.dirname(os.path.abspath(__file__))
+config_path = os.path.join(script_path, 'config.ini')
+
+if len(config.read(config_path)) == 0:
+ print 'Can\'t load configuration file.'
+ sys.exit(-1)
+
+base_url = config.get('server', 'base_url')
+url_componets = urlparse(base_url)
+
+ACTIVITIES_DOMAIN = url_componets.netloc
+HOST_FILE = '/etc/hosts'
+HTTPD_CONFIG = '/etc/httpd/conf.d'
+
+def setup_host():
+ host_file = open(HOST_FILE, 'a')
+ content = host_file.read()
+
+ if content.find(ACTIVITIES_DOMAIN) == -1:
+ host_file.write('127.0.0.1 %s\n' % ACTIVITIES_DOMAIN)
+
+ host_file.close()
+
+def setup_httpd_config():
+ config_path = os.path.join(HTTPD_CONFIG, 'dx-activity-server.conf')
+ config_file = open(config_path, 'w')
+
+ content = '''
+ <VirtualHost *:80>
+ DocumentRoot /var/www/dx-activity-server
+ ServerName %s
+ </VirtualHost>
+ ''' % ACTIVITIES_DOMAIN
+
+ config_file.write(content)
+ config_file.close()
+
+def main():
+ setup_host()
+ setup_httpd_config()
+ print 'setup finished successfully.'
+ sys.exit(0)
+
+if __name__ == "__main__":
+ main()