mirror of
https://github.com/zulip/zulip.git
synced 2025-10-27 01:53:59 +00:00
Commit split by tabbott; this has changes to scripts/, tools/, and
puppet/.
scripts/lib/hash_reqs.py, scripts/lib/setup_venv.py,
scripts/lib/zulip_tools.py, and tools/lib/provision.py are excluded so
tools/provision still gives the right error message on Ubuntu 16.04
with Python 3.5.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
-shebang_rules: List[Rule] = [
+shebang_rules: List["Rule"] = [
-trailing_whitespace_rule: Rule = {
+trailing_whitespace_rule: "Rule" = {
-whitespace_rules: List[Rule] = [
+whitespace_rules: List["Rule"] = [
-comma_whitespace_rule: List[Rule] = [
+comma_whitespace_rule: List["Rule"] = [
-prose_style_rules: List[Rule] = [
+prose_style_rules: List["Rule"] = [
-html_rules: List[Rule] = whitespace_rules + prose_style_rules + [
+html_rules: List["Rule"] = whitespace_rules + prose_style_rules + [
- target_port: int = None
+ target_port: int
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
61 lines
2.4 KiB
Python
Executable File
61 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import subprocess
|
|
import logging
|
|
import time
|
|
import configparser
|
|
|
|
TARBALL_ARCHIVE_PATH = "/home/zulip/archives"
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, \
|
|
su_to_zulip, get_deployment_lock, release_deployment_lock, assert_running_as_root, \
|
|
get_config_file, get_deploy_options
|
|
|
|
config_file: configparser.RawConfigParser = get_config_file()
|
|
deploy_options = get_deploy_options(config_file)
|
|
|
|
assert_running_as_root(strip_lib_from_paths=True)
|
|
|
|
logging.Formatter.converter = time.gmtime
|
|
logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s",
|
|
level=logging.INFO)
|
|
|
|
if len(sys.argv) != 2:
|
|
print(FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC)
|
|
sys.exit(1)
|
|
|
|
tarball_path = sys.argv[1]
|
|
|
|
error_rerun_script = "%s/current/scripts/upgrade-zulip %s" % (DEPLOYMENTS_DIR, tarball_path)
|
|
get_deployment_lock(error_rerun_script)
|
|
|
|
try:
|
|
# Copy the release tarball to an archival path that's readable by
|
|
# the Zulip user, and then unpack it from that directory, so that
|
|
# we can unpack using the Zulip user even if the original path was
|
|
# not readable by the Zulip user.
|
|
logging.info("Archiving the tarball under %s" % (TARBALL_ARCHIVE_PATH,))
|
|
os.makedirs(TARBALL_ARCHIVE_PATH, exist_ok=True)
|
|
archived_tarball_path = os.path.join(TARBALL_ARCHIVE_PATH, os.path.basename(tarball_path))
|
|
shutil.copy(tarball_path, archived_tarball_path)
|
|
subprocess.check_output(["chown", "-R", "zulip:zulip", TARBALL_ARCHIVE_PATH])
|
|
|
|
logging.info("Unpacking the tarball")
|
|
unpack_zulip = os.path.realpath(os.path.join(os.path.dirname(__file__), 'unpack-zulip'))
|
|
deploy_path = subprocess.check_output([unpack_zulip, archived_tarball_path],
|
|
preexec_fn=su_to_zulip, universal_newlines=True)
|
|
|
|
# Chdir to deploy_path and then run upgrade-zulip-stage-2 from the
|
|
# new version of Zulip (having the upgrade logic run from the new
|
|
# version is much better for fixing bugs in the upgrade process).
|
|
deploy_path = deploy_path.strip()
|
|
os.chdir(deploy_path)
|
|
subprocess.check_call([os.path.abspath("./scripts/lib/upgrade-zulip-stage-2"), deploy_path]
|
|
+ deploy_options)
|
|
finally:
|
|
release_deployment_lock()
|