aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2013-01-23 13:17:41 +0100
committerMilo Casagrande <milo@ubuntu.com>2013-01-23 13:17:41 +0100
commit8b13b001b6e80764f464c43244b997f0387c2dfe (patch)
tree847056aff4e933f239578e92b25221cd03ab9ba9
parent2a0888a08b11eb547dc8fe2d576639b7af5e4d3a (diff)
Added function to set up permissions, create celery log dir.
-rw-r--r--scripts/rhodecode-setup29
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup
index 9df27cd..5d7b300 100644
--- a/scripts/rhodecode-setup
+++ b/scripts/rhodecode-setup
@@ -63,6 +63,9 @@ POSTGRES_ROLE = "rhodecode"
# Default directory where to store git repositories.
REPOS_DIR = "/opt/git_repos"
+# Default Celery log directory
+CELERY_LOG_DIR = "/var/log/celery"
+
def cli_args():
"""Sets up the cli argument parser."""
@@ -110,6 +113,10 @@ def cli_args():
parser.add_argument("--no-celery",
action="store_true",
help="If Celery integration should be disabled.")
+ parser.add_argument("--celery-log-dir",
+ default=CELERY_LOG_DIR,
+ help="The Celery log directory. Defaults to '%s'." %
+ CELERY_LOG_DIR)
parser.add_argument("--rabbitmq-usr",
default=RABBITMQ_DEFAULT_USER,
help="The name to use for the RabbitMQ session. "
@@ -180,7 +187,7 @@ def setup_user(user, home_dir, group):
execute_command(cmd_args)
-def setup_directories(data_dir, repos_dir, rhodecode_usr):
+def setup_directories(data_dir, repos_dir, celery_log_dir, rhodecode_usr):
if not os.path.exists(data_dir):
cmd_args = ["mkdir", "-p", data_dir]
execute_command(cmd_args)
@@ -189,11 +196,18 @@ def setup_directories(data_dir, repos_dir, rhodecode_usr):
cmd_args = ["mkdir", "-p", repos_dir]
execute_command(cmd_args)
+ if not os.path.exists(celery_log_dir):
+ cmd_args = ["mkdir", "-p", celery_log_dir]
+ execute_command(cmd_args)
+
# Set ownership of the directories to the RhodeCode user.
set_owners(data_dir, rhodecode_usr)
set_owners(repos_dir, rhodecode_usr)
+ set_owners(celery_log_dir, rhodecode_usr)
+ set_permissions(celery_log_dir, "g+w")
+
def execute_command(cmd_args,
work_dir=os.getcwd(),
@@ -395,6 +409,18 @@ def set_owners(directory, usr, group=None):
execute_command(cmd_args)
+def set_permissions(file_or_dir, permissions):
+ """Sets the permissions on the given path.
+
+ :param file_or_dir: The path to what the permissions should be set.
+ :type str
+ :param permissions: String containing the permissions as passed to the
+ 'chmod' command.
+ """
+ cmd_args = ["chmod", "-R", permissions, file_or_dir]
+ execute_command(cmd_args)
+
+
def install_rhodecode(work_dir, user=None):
"""Installs RhodeCode on the system.
@@ -523,6 +549,7 @@ if __name__ == '__main__':
# Create the necessary directories to store RhodeCode data and cache.
setup_directories(args.rhodecode_data_dir,
args.repos_dir,
+ args.celery_log_dir,
args.rhodecode_usr)
# Take git-core package from Launchpad PPA of git maintainers.