diff options
author | Milo Casagrande <milo@ubuntu.com> | 2013-01-23 18:14:42 +0100 |
---|---|---|
committer | Milo Casagrande <milo@ubuntu.com> | 2013-01-23 18:14:42 +0100 |
commit | c4422f47228b675c7810799d71ab126720ae7590 (patch) | |
tree | 845557c209be378a3b0612294541f6d725dc9535 /scripts/rhodecode-setup | |
parent | 231329b46f97c5a0bd1e9a83cc8ea2af4d7a7ee8 (diff) |
Added Apache steps.
Diffstat (limited to 'scripts/rhodecode-setup')
-rw-r--r-- | scripts/rhodecode-setup | 93 |
1 files changed, 87 insertions, 6 deletions
diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 3aee22d..dfea028 100644 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -21,7 +21,7 @@ CELERY_REQUIRED_PACKAGES = ["rabbitmq-server"] # Packages for the backend to use. SQLITE_DB = "sqlite" -POSTGRESQL_DB = ["postgresql-9.1", "pgadmin3", "postgresql-server-dev-9.1"] +POSTGRESQL_DB = ["postgresql-9.1"] # The name of the DB for PostgreSQL. DB_NAME = "rhodecode" @@ -66,6 +66,15 @@ CELERY_LOG_DIR = "/var/log/celery" # Default RhodeCode log directory. RHODECODE_LOG_DIR = "/var/log/rhodecode" +# Relative path to the Apache RhodeCode website configuration. +APACHE_WEBSITE_CONF = "../config/rhodecode" +# Default websites directory. +APACHE_DEFAULT_DIR = "/etc/apache2/sites-available/" +# Default modules to enalbe in Apache +APACHE_ENABLE_MODULES = ["proxy", "proxy_http"] +# Apache websites to disable. +APACHE_DISABLE_SITES = ["default"] + def cli_args(): """Sets up the cli argument parser.""" @@ -147,6 +156,14 @@ def cli_args(): parser.add_argument("--postgres-role-pwd", required=True, help="The password for the PostgreSQL role.") + parser.add_argument("--apache-conf", + default=APACHE_WEBSITE_CONF, + help="Path to the Apache RhodeCode configuration. " + "Defaults to '%s'." % APACHE_WEBSITE_CONF) + parser.add_argument("--apache-website-dir", + default=APACHE_DEFAULT_DIR, + help="Path the the Apache sites directory. Defaults " + "to '%s'." % APACHE_DEFAULT_DIR) return parser.parse_args() @@ -496,13 +513,64 @@ def copy_file(source, dest): execute_command(cmd_args) -def start_services(no_celery): - """Starts the installed services. +def start_service(service): + """Starts a service. - :param no_celery: If Celery has to be started or not. - :type bool + Start a service by using the 'service' command. + + :param service: The service to start. + :type str """ - pass + cmd_args = ["service", service, "start"] + execute_command(cmd_args) + + +def reload_apache_service(): + """Reloads Apache configuration.""" + cmd_args = ["service", "apache2", "reload"] + execute_command(cmd_args) + + +def disable_apache_sites(sites): + """Disables Apache sites. + + :param sites: The list of sites to disable. + :type list + """ + if not isinstance(sites, list): + sites = [sites] + + for site in sites: + cmd_args = ["a2dissite", site] + execute_command(cmd_args) + + +def enable_apache_sites(sites): + """Enables Apache sites. + + :param sites: The list of sites to enable. + :type list + """ + if not isinstance(sites, list): + sites = [sites] + + for site in sites: + cmd_args = ["a2ensite", site] + execute_command(cmd_args) + + +def enable_apache_modules(modules): + """Enables Apache modules. + + :param modules: List of modules to enable. + :type list + """ + if not isinstance(modules, list): + modules = [modules] + + for module in modules: + cmd_args = ["a2enmod", module] + execute_command(cmd_args) def print_install_report(args, home_dir, config_file): @@ -604,6 +672,19 @@ if __name__ == '__main__': args.rhodecode_admin_email, args.rhodecode_usr) + # Apache configurations. + apache_conf = os.path.abspath(args.apache_conf) + copy_file(apache_conf, args.apache_default_dir) + + disable_apache_sites(APACHE_DISABLE_SITES) + enable_apache_modules(APACHE_ENABLE_MODULES) + reload_apache_service() + + # Install upstart scripts for Celery and RhodeCode install_upstart_conf(args.no_celery) + start_service("rhodecode") + + if not args.no_celery: + start_service("celeryd") print_install_report(args, home_dir, rhodecode_conf) |