diff --git a/scripts/lib/upgrade-zulip b/scripts/lib/upgrade-zulip index c369eaaa3c..1c40495d18 100755 --- a/scripts/lib/upgrade-zulip +++ b/scripts/lib/upgrade-zulip @@ -11,16 +11,14 @@ os.environ["PYTHONUNBUFFERED"] = "y" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, \ - su_to_zulip, get_deployment_lock, release_deployment_lock + su_to_zulip, get_deployment_lock, release_deployment_lock, script_should_be_root + +script_should_be_root(strip_lib_from_paths=True) logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s", level=logging.INFO) -if os.getuid() != 0: - logging.error("Must be run as root.") - sys.exit(1) - if len(sys.argv) != 2: print(FAIL + "Usage: %s " % (sys.argv[0],) + ENDC) sys.exit(1) diff --git a/scripts/lib/upgrade-zulip-from-git b/scripts/lib/upgrade-zulip-from-git index 697706c0cb..9904cf61d7 100755 --- a/scripts/lib/upgrade-zulip-from-git +++ b/scripts/lib/upgrade-zulip-from-git @@ -24,16 +24,14 @@ os.environ["PYTHONUNBUFFERED"] = "y" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, make_deploy_path, \ - get_deployment_lock, release_deployment_lock, su_to_zulip + get_deployment_lock, release_deployment_lock, su_to_zulip, script_should_be_root + +script_should_be_root(strip_lib_from_paths=True) logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip-from-git: %(message)s", level=logging.INFO) -if os.getuid() != 0: - logging.error("Must be run as root.") - sys.exit(1) - parser = argparse.ArgumentParser() parser.add_argument("refname", help="Git reference, e.g. a branch, tag, or commit ID.") parser.add_argument("--remote-url", dest="remote_url", diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 3bbcc199e3..33e0e8c514 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -20,16 +20,14 @@ os.environ["LANG"] = "en_US.UTF-8" os.environ["LANGUAGE"] = "en_US.UTF-8" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) -from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip +from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip, script_should_be_root + +script_should_be_root() logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip-stage-2: %(message)s", level=logging.INFO) -if os.getuid() != 0: - logging.error("Must be run as root.") - sys.exit(1) - # make sure we have appropriate file permissions os.umask(0o22)