aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStevan Radaković <stevan.radakovic@linaro.org>2013-04-01 14:39:37 +0200
committerStevan Radaković <stevan.radakovic@linaro.org>2013-04-01 14:39:37 +0200
commit7d292a7d53ebad60da77c3ed65599b0a7ebbc75a (patch)
treeddb24a4d2e7a7a19004e22172e29ee6d40f83383
parent14575cae184112b1a653969d9c3891df631897b7 (diff)
Add script for changing repo path permissions. Create a setup step for preparing it.
-rw-r--r--scripts/change-repo-ownership22
-rwxr-xr-xscripts/rhodecode-setup28
2 files changed, 49 insertions, 1 deletions
diff --git a/scripts/change-repo-ownership b/scripts/change-repo-ownership
new file mode 100644
index 0000000..3e6cc9b
--- /dev/null
+++ b/scripts/change-repo-ownership
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Copyright (C) 2013 Linaro Ltd.
+#
+# 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 3 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/>
+
+if [ $# -eq 0 ]
+ then
+ echo "No arguments supplied. Please provide repo path and group."
+fi
+
+sudo chown -R $RHODECODE_USER:$2 $RHODECODE_DATA_PATH/$1
diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup
index 00c620c..fe69740 100755
--- a/scripts/rhodecode-setup
+++ b/scripts/rhodecode-setup
@@ -17,6 +17,7 @@
import argparse
import datetime
+import fileinput
import os
import subprocess
import sys
@@ -88,7 +89,10 @@ APACHE_DEFAULT_DIR = "/etc/apache2/sites-available/"
APACHE_ENABLE_MODULES = ["proxy", "proxy_http", "expires", "headers", "ssl"]
# Apache websites to disable.
APACHE_DISABLE_SITES = ["default"]
-
+# Chown script constants.
+CHOWN_SCRIPT_NAME = "change-repo-ownership"
+CHOWN_SCRIPT_USER = "$RHODECODE_USER"
+CHOWN_SCRIPT_PATH = "$RHODECODE_DATA_PATH"
def cli_args():
"""Sets up the cli argument parser."""
@@ -553,6 +557,25 @@ def update_database_schema(work_dir, config_file, assume_yes=False):
execute_command(cmd_args, work_dir=work_dir, input_str=input_str,
continue_on_error=True)
+def prepare_chown_script(rhodecode_usr, repos_dir):
+ """ Update the script with correct values for user and base repo dir.
+
+ Copy the script to /usr/bin dir and set chmod +x.
+ :param rhodecode_usr: Rhodecode system username.
+ :type str
+ :param repos_dir: Rhodecode repo path.
+ :type str
+ """
+ for line in fileinput.input(CHOWN_SCRIPT_NAME, inplace=1):
+ if CHOWN_SCRIPT_USER in line:
+ line = line.replace(CHOWN_SCRIPT_USER, rhodecode_usr)
+ line = line.replace(CHOWN_SCRIPT_PATH, repos_dir)
+ print line,
+
+ cmd_args = ["chmod", "+x", "CHOWN_SCRIPT_NAME"]
+ execute_command(cmd_args, with_sudo=True)
+ cmd_args = ["cp", "CHOWN_SCRIPT_NAME", "/usr/bin"]
+ execute_command(cmd_args, with_sudo=True)
def backup_installation(home_dir):
"""Backup the old code base and installation in home directory.
@@ -784,6 +807,9 @@ if __name__ == '__main__':
# Update database schema.
update_database_schema(work_dir, rhodecode_conf, True)
+ # Prepare chown script.
+ prepare_chown_script(args.rhodecode_usr, args.repos_dir)
+
# Start rhodecode and celery.
start_service("rhodecode")