From e8c104012bd9614a4a2df84eede78af5c73ffca8 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 13 Nov 2013 15:54:30 -0500 Subject: [PATCH] Move su_to_zulip into zulip_tools.py (imported from commit 4a79f87dc396da9419a0a1cf5f5b7bb798d5b194) --- scripts/upgrade-zulip | 9 ++------- zulip_tools.py | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade-zulip b/scripts/upgrade-zulip index 0887cdd9ab..8669866a70 100755 --- a/scripts/upgrade-zulip +++ b/scripts/upgrade-zulip @@ -6,10 +6,10 @@ import logging import datetime import shutil import time -import pwd sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC +from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, \ + su_to_zulip logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s", level=logging.INFO) @@ -44,11 +44,6 @@ if not got_lock: + ENDC sys.exit(1) -def su_to_zulip(): - pwent = pwd.getpwnam("zulip") - os.setgid(pwent.pw_gid) - os.setuid(pwent.pw_uid) - logging.info("Unpacking the tarball") deploy_path = subprocess.check_output([os.path.join(os.path.dirname(__file__), 'unpack-zulip'), tarball_path], preexec_fn=su_to_zulip) diff --git a/zulip_tools.py b/zulip_tools.py index 08650c72ac..18fe694851 100755 --- a/zulip_tools.py +++ b/zulip_tools.py @@ -2,6 +2,7 @@ import os import sys import datetime +import pwd DEPLOYMENTS_DIR = "/home/zulip/deployments" LOCK_DIR = os.path.join(DEPLOYMENTS_DIR, "lock") @@ -14,6 +15,11 @@ WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' +def su_to_zulip(): + pwent = pwd.getpwnam("zulip") + os.setgid(pwent.pw_gid) + os.setuid(pwent.pw_uid) + def make_deploy_path(): timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT) return os.path.join(DEPLOYMENTS_DIR, timestamp)