2016-04-07 15:03:22 +02:00
|
|
|
#!/usr/bin/env python
|
2016-03-10 17:15:34 +01:00
|
|
|
from __future__ import print_function
|
2013-11-08 22:41:12 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import datetime
|
|
|
|
import tempfile
|
2013-11-14 04:51:46 +01:00
|
|
|
import glob
|
2013-11-08 22:41:12 +01:00
|
|
|
|
2015-11-16 17:40:32 +01:00
|
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
|
2013-11-14 16:35:21 +01:00
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', ".."))
|
2017-06-21 14:32:22 +02:00
|
|
|
from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path, \
|
|
|
|
get_deployment_version, is_invalid_upgrade
|
|
|
|
import version
|
2013-11-08 22:41:12 +01:00
|
|
|
|
|
|
|
if len(sys.argv) != 2:
|
2016-03-10 17:15:34 +01:00
|
|
|
print(FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC)
|
2013-11-08 22:41:12 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
tarball_path = sys.argv[1]
|
|
|
|
|
2013-11-13 20:57:31 +01:00
|
|
|
deploy_path = make_deploy_path()
|
2013-11-08 22:41:12 +01:00
|
|
|
|
|
|
|
extract_path = tempfile.mkdtemp()
|
|
|
|
subprocess.check_call(["tar", "-xf", tarball_path, "-C", extract_path])
|
2017-06-21 14:32:22 +02:00
|
|
|
|
|
|
|
new_version = get_deployment_version(extract_path)
|
|
|
|
current_version = version.ZULIP_VERSION
|
|
|
|
if is_invalid_upgrade(current_version, new_version):
|
|
|
|
print(FAIL +
|
|
|
|
"Your current version is very old. Please first upgrade to version "
|
|
|
|
"1.4.3 and then upgrade to {}.".format(new_version) +
|
|
|
|
ENDC)
|
|
|
|
subprocess.check_call(["rm", "-r", extract_path])
|
|
|
|
sys.exit(1)
|
|
|
|
|
2013-11-14 04:51:46 +01:00
|
|
|
subprocess.check_call(["mv", glob.glob(os.path.join(extract_path, "zulip-server-*"))[0], deploy_path])
|
2013-11-08 22:41:12 +01:00
|
|
|
subprocess.check_call(["rmdir", extract_path])
|
2013-11-08 23:13:56 +01:00
|
|
|
subprocess.check_call(["ln", "-nsf", "/etc/zulip/settings.py",
|
2016-07-20 05:42:43 +02:00
|
|
|
os.path.join(deploy_path, "zproject/prod_settings.py")])
|
2013-11-13 21:04:07 +01:00
|
|
|
subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "next")])
|
2013-11-08 22:41:12 +01:00
|
|
|
|
2016-03-10 17:15:34 +01:00
|
|
|
print(deploy_path)
|
2013-11-08 22:41:12 +01:00
|
|
|
sys.exit(0)
|