From 0396791e7c8d68f1edc5e5ee07d5d5dbdeb48768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:05:17 +0100 Subject: Change requirement dependencies for --update option. --- scripts/rhodecode-setup | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 2b359d6..0b0fefc 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -16,7 +16,7 @@ REQUIRED_PACKAGES = ["python-pip", "python-webob", "python-bcrypt", "python-formencode", "python-pylons", "python-dev", "python-pastescript", "python-psycopg2", "python-nose", "build-essential", "python-amqplib", "python-anyjson", - "python-mailer", "apache2", "git-core"] + "python-mailer", "apache2", "git"] # Packages required for celery integration. CELERY_REQUIRED_PACKAGES = ["rabbitmq-server"] @@ -175,16 +175,12 @@ def check_cli_args(args): Logic to handle the various cases for the cli args. :param args: The args passed on the command line. """ + # Checks for required options during update. if not args.rhodecode_config: print ("It is necessary to specify the path to RhodeCode " "configuration file.") sys.exit(1) - if not args.rhodecode_admin_pwd: - print ("It is necessary to specify the administration password for " - "RhodeCode") - sys.exit(1) - # Checks for required options during update. if args.update: if not args.rhodecode_usr: print ("During update it is necessary to specify the RhodeCode" @@ -199,6 +195,12 @@ def check_cli_args(args): "database name.") sys.exit(1) + else: + if not args.rhodecode_admin_pwd: + print ("It is necessary to specify the administration " + "password for RhodeCode") + sys.exit(1) + if not args.no_celery: if (args.rabbitmq_usr == RABBITMQ_DEFAULT_USER or \ args.rabbitmq_vhost == RABBITMQ_DEFAULT_VHOST): -- cgit v1.2.3 From 28bd549ea71b415bcfb3b68c2fdc56a54399f6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:09:51 +0100 Subject: Remove requirements in option settings, move them to the check_cli_args method. --- scripts/rhodecode-setup | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 0b0fefc..2d72fd6 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -95,8 +95,7 @@ def cli_args(): default=RHODECODE_ADMIN_USER, help="The name of the admin user for RhodeCode.") parser.add_argument("--rhodecode-admin-pwd", - help="The password for RhodeCode admin user.", - required=True) + help="The password for RhodeCode admin user.") parser.add_argument("--rhodecode-admin-email", required=True, help="The email address for RhodeCode admin user.") @@ -135,8 +134,7 @@ def cli_args(): help="The name to use for the RabbitMQ session. " "Defaults to '%s'." % RABBITMQ_DEFAULT_USER) parser.add_argument("--rabbitmq-pwd", - help="The password for the RabbitMQ user.", - required=True) + help="The password for the RabbitMQ user.") parser.add_argument("--rabbitmq-vhost", default=RABBITMQ_DEFAULT_VHOST, help="The name of the RabbitMQ vhost for the user. " @@ -154,13 +152,11 @@ def cli_args(): help="The PostgreSQL role to create. Defaults " "to '%s'." % POSTGRES_ROLE) parser.add_argument("--postgres-role-pwd", - required=True, help="The password for the PostgreSQL role.") parser.add_argument("--update", action="store_true", help="Updates to the latest tagged version.") parser.add_argument("--apache-conf", - required=True, help="Path to the Apache RhodeCode configuration.") parser.add_argument("--apache-website-dir", default=APACHE_DEFAULT_DIR, @@ -200,6 +196,22 @@ def check_cli_args(args): print ("It is necessary to specify the administration " "password for RhodeCode") sys.exit(1) + if not args.rhodecode_admin_email: + print ("It is necessary to specify the administration " + "email for RhodeCode") + sys.exit(1) + if not args.apache_conf: + print ("It is necessary to specify the path to apache " + "configuration file") + sys.exit(1) + if not args.postgres_role_pwd: + print ("It is necessary to specify the PostgreSQL " + "user password") + sys.exit(1) + if not args.rabbitmq_pwd: + print ("It is necessary to specify the RabbitMQ " + "password") + sys.exit(1) if not args.no_celery: if (args.rabbitmq_usr == RABBITMQ_DEFAULT_USER or \ -- cgit v1.2.3 From b1ed265ef947529be55993bb66e65001cba4e2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:10:43 +0100 Subject: Missed deleting one more required option. --- scripts/rhodecode-setup | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 2d72fd6..66102f8 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -97,7 +97,6 @@ def cli_args(): parser.add_argument("--rhodecode-admin-pwd", help="The password for RhodeCode admin user.") parser.add_argument("--rhodecode-admin-email", - required=True, help="The email address for RhodeCode admin user.") parser.add_argument("--rhodecode-usr", default=RHODECODE_DEFAULT_USER, -- cgit v1.2.3 From 69495b132a78eb864773f2a559a9e89772daf98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:12:55 +0100 Subject: Fix typo for dbname argument. --- scripts/rhodecode-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 66102f8..6ec8c11 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -185,7 +185,7 @@ def check_cli_args(args): print ("During update it is necessary to specify the RhodeCode" "checkout directory.") sys.exit(1) - if not args.db_name: + if not args.dbname: print ("During update it is necessary to specify the RhodeCode" "database name.") sys.exit(1) -- cgit v1.2.3 From 5e0dc070479053bf9e07d27f1b0db7d9ff6d936f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:13:54 +0100 Subject: Indent celery options correctly. --- scripts/rhodecode-setup | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 6ec8c11..7769bcc 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -212,16 +212,16 @@ def check_cli_args(args): "password") sys.exit(1) - if not args.no_celery: - if (args.rabbitmq_usr == RABBITMQ_DEFAULT_USER or \ - args.rabbitmq_vhost == RABBITMQ_DEFAULT_VHOST): - print ("Warning: default values for --rabbitmq-user and/or " - "--rabbitmq-vhost are being used.") - - if not args.rabbitmq_pwd: - print ("To setup RhodeCode to correctly use Celery, it is " - "necessary to specify also the RabbitMQ user password.") - sys.exit(1) + if not args.no_celery: + if (args.rabbitmq_usr == RABBITMQ_DEFAULT_USER or \ + args.rabbitmq_vhost == RABBITMQ_DEFAULT_VHOST): + print ("Warning: default values for --rabbitmq-user and/or " + "--rabbitmq-vhost are being used.") + + if not args.rabbitmq_pwd: + print ("To setup RhodeCode to correctly use Celery, it is " + "necessary to specify also the RabbitMQ user password.") + sys.exit(1) def setup_user(user, home_dir, group): -- cgit v1.2.3 From 35b56419405b89d128a071437549d04e6ed4bb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:50:42 +0100 Subject: pg_dump from now on works with postgres user. --- scripts/rhodecode-setup | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 7769bcc..f348d6b 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -7,6 +7,7 @@ import datetime import os import subprocess import sys +import tempfile DESCRIPTION = "Install and setup RhodeCode Linaro instance." @@ -539,7 +540,7 @@ def backup_installation(home_dir): execute_command(cmd_args, work_dir=home_dir) -def backup_postgres_db(home_dir, db_name): +def backup_postgres_db(home_dir, db_name, postgres_usr="postgres"): """Backup the database as file in home directory. :param home_dir: Working directory. @@ -548,9 +549,17 @@ def backup_postgres_db(home_dir, db_name): :type str """ date = datetime.date.today() - db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) - cmd_args = ["pg_dump", db_name, ">", DB_BACKUP_FILENAME] - execute_command(cmd_args, work_dir=home_dir) + try: + tempfile = tempfile.NamedTemporaryFile() + db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) + cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", + tempfile.name] + execute_command(cmd_args, work_dir=home_dir) + + cmd_args = ["cp", tempfile.name, DB_BACKUP_FILENAME] + execute_command(cmd_args, work_dir=home_dir) + finally: + tempfile.close() def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, -- cgit v1.2.3 From 97059be1cdb0368fade3155a0dda05403d7c7a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:52:53 +0100 Subject: Move tempfile init outside of try block. --- scripts/rhodecode-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index f348d6b..eadf49c 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -549,8 +549,8 @@ def backup_postgres_db(home_dir, db_name, postgres_usr="postgres"): :type str """ date = datetime.date.today() + tempfile = tempfile.NamedTemporaryFile() try: - tempfile = tempfile.NamedTemporaryFile() db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", tempfile.name] -- cgit v1.2.3 From dd29e1b05cbceb6c360ffb1e831f27d69d5c8274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 16:54:11 +0100 Subject: Rename tempfile var. --- scripts/rhodecode-setup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index eadf49c..f0f7a32 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -549,17 +549,17 @@ def backup_postgres_db(home_dir, db_name, postgres_usr="postgres"): :type str """ date = datetime.date.today() - tempfile = tempfile.NamedTemporaryFile() + temp = tempfile.NamedTemporaryFile() try: db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", - tempfile.name] + temp.name] execute_command(cmd_args, work_dir=home_dir) - cmd_args = ["cp", tempfile.name, DB_BACKUP_FILENAME] + cmd_args = ["cp", temp.name, DB_BACKUP_FILENAME] execute_command(cmd_args, work_dir=home_dir) finally: - tempfile.close() + temp.close() def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, -- cgit v1.2.3 From e88f5f54330b6f6a207d3b398985bb6f6b056b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:11:41 +0100 Subject: Use /tmp directory for pg_dump output. --- scripts/rhodecode-setup | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index f0f7a32..7bbc3fc 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -7,7 +7,6 @@ import datetime import os import subprocess import sys -import tempfile DESCRIPTION = "Install and setup RhodeCode Linaro instance." @@ -549,17 +548,13 @@ def backup_postgres_db(home_dir, db_name, postgres_usr="postgres"): :type str """ date = datetime.date.today() - temp = tempfile.NamedTemporaryFile() - try: - db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) - cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", - temp.name] - execute_command(cmd_args, work_dir=home_dir) - - cmd_args = ["cp", temp.name, DB_BACKUP_FILENAME] - execute_command(cmd_args, work_dir=home_dir) - finally: - temp.close() + tempfile_name = "/%s/%s" % ("tmp", DB_BACKUP_FILENAME) + db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d")) + cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", tempfile_name] + execute_command(cmd_args, work_dir=home_dir) + + cmd_args = ["cp", tempfile_name, DB_BACKUP_FILENAME] + execute_command(cmd_args, work_dir=home_dir) def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, -- cgit v1.2.3 From 3a9a1f9fa6d6b5870f7b1e53d16328f49e273270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:13:00 +0100 Subject: Add --rhodecode-tag option to be mandatory --- scripts/rhodecode-setup | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 7bbc3fc..bc72898 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -181,6 +181,10 @@ def check_cli_args(args): print ("During update it is necessary to specify the RhodeCode" "system user.") sys.exit(1) + if not args.rhodecode_tag: + print ("During update it is necessary to specify the RhodeCode" + "repository tag to use (i.e. v1.5.1).") + sys.exit(1) if not args.rhodecode_checkout_dir: print ("During update it is necessary to specify the RhodeCode" "checkout directory.") -- cgit v1.2.3 From 04798e9ae105a6a87b45704c1390aecaaa6af934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:17:57 +0100 Subject: Use rhodecode_branch option instead of _tag one. --- scripts/rhodecode-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index bc72898..179e8a8 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -181,7 +181,7 @@ def check_cli_args(args): print ("During update it is necessary to specify the RhodeCode" "system user.") sys.exit(1) - if not args.rhodecode_tag: + if not args.rhodecode_branch: print ("During update it is necessary to specify the RhodeCode" "repository tag to use (i.e. v1.5.1).") sys.exit(1) @@ -752,7 +752,7 @@ if __name__ == '__main__': backup_postgres_db(home_dir, args.dbname) # Update the rhodecode code base. Reinstall Rhodecode. - update_rhodecode(args.rhodecode_tag, work_dir) + update_rhodecode(args.rhodecode_branch, work_dir) reinstall_rhodecode(work_dir) # Update database schema. -- cgit v1.2.3 From 33c35a9e40ffd4598ea53b7d9dd0e99e13e706c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:26:07 +0100 Subject: Fix error with backup db filename and with rhodecode config path. --- scripts/rhodecode-setup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 179e8a8..cc62cbb 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -557,7 +557,7 @@ def backup_postgres_db(home_dir, db_name, postgres_usr="postgres"): cmd_args = ["-u", postgres_usr, "pg_dump", db_name, "-f", tempfile_name] execute_command(cmd_args, work_dir=home_dir) - cmd_args = ["cp", tempfile_name, DB_BACKUP_FILENAME] + cmd_args = ["cp", tempfile_name, db_filename] execute_command(cmd_args, work_dir=home_dir) @@ -741,6 +741,8 @@ if __name__ == '__main__': home_dir = os.path.join("/home", args.rhodecode_usr) work_dir = os.path.join(home_dir, args.rhodecode_checkout_dir) + rhodecode_conf = os.path.join(home_dir, + os.path.basename(args.rhodecode_config)) if args.update: # Stop rhodecode @@ -756,7 +758,7 @@ if __name__ == '__main__': reinstall_rhodecode(work_dir) # Update database schema. - update_database_schema(work_dir, args.rhodecode_config) + update_database_schema(work_dir, rhodecode_conf) # Start rhodecode and celery. start_service("rhodecode") @@ -818,8 +820,6 @@ if __name__ == '__main__': set_owners(work_dir, args.rhodecode_usr) install_rhodecode(work_dir, args.rhodecode_usr) - rhodecode_conf = os.path.join(home_dir, - os.path.basename(args.rhodecode_config)) copy_file(args.rhodecode_config, home_dir) set_owners(rhodecode_conf, args.rhodecode_usr) -- cgit v1.2.3 From 7deb3ac0fcd997946c8f2768d2bed4b96331d5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:28:03 +0100 Subject: Add assume-yes support for updating db schema. --- scripts/rhodecode-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index cc62cbb..d3fa646 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -526,8 +526,12 @@ def update_database_schema(work_dir, config_file): :param config_file: Config file to use, it will tell which db to update. :type str """ + input_str = None + if assume_yes: + input_str = "y" + cmd_args = ["paster", "upgrade-db", config_file] - execute_command(cmd_args, work_dir=work_dir) + execute_command(cmd_args, work_dir=work_dir, input_str=input_str) def backup_installation(home_dir): -- cgit v1.2.3 From 54cbb492bd74a89ea7a1cacf5b6e3bdc3fae4e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:28:51 +0100 Subject: Add assume-yes support for updating db schema. --- scripts/rhodecode-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index d3fa646..594ae93 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -518,7 +518,7 @@ def update_rhodecode(tag, work_dir): execute_command(cmd_args, work_dir=work_dir, with_sudo=True) -def update_database_schema(work_dir, config_file): +def update_database_schema(work_dir, config_file, assume_yes=False): """Updates the database schema regardles of the database used. :param work_dir: Working directory. @@ -762,7 +762,7 @@ if __name__ == '__main__': reinstall_rhodecode(work_dir) # Update database schema. - update_database_schema(work_dir, rhodecode_conf) + update_database_schema(work_dir, rhodecode_conf, True) # Start rhodecode and celery. start_service("rhodecode") -- cgit v1.2.3 From 47ac5bfe9ef305edec3692a3b8e0795ae87da456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Mon, 28 Jan 2013 17:31:58 +0100 Subject: paster update-db return code is not 0 when the DB version is newest, so we have to add continue_on_error here. --- scripts/rhodecode-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 594ae93..7f7d73e 100755 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -531,7 +531,8 @@ def update_database_schema(work_dir, config_file, assume_yes=False): input_str = "y" cmd_args = ["paster", "upgrade-db", config_file] - execute_command(cmd_args, work_dir=work_dir, input_str=input_str) + execute_command(cmd_args, work_dir=work_dir, input_str=input_str, + continue_on_error=True) def backup_installation(home_dir): -- cgit v1.2.3