mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
upgrade-zulip: Archive release tarballs at /home/zulip/archives.
A common issue when doing a Zulip upgrade is trying to pass upgrade-zulip a tarball path under /root, which doesn't work because the Zulip user doesn't have permission to read the tarball. We could fix this by just unpacking the tarballs as root, but it seemed like a nicer approach would be to archive the release tarballs somewhere readable by the Zulip user (/home/zulip/archives) and unpack them from there. Fixes #208.
This commit is contained in:
@@ -343,14 +343,10 @@ upgrade.
|
|||||||
|
|
||||||
* To upgrade to a new version of the zulip server, download the
|
* To upgrade to a new version of the zulip server, download the
|
||||||
appropriate release tarball from
|
appropriate release tarball from
|
||||||
https://www.zulip.com/dist/releases/ to a path readable by the zulip
|
https://www.zulip.com/dist/releases/ and then run as root:
|
||||||
user (e.g. /home/zulip), and then run as root:
|
|
||||||
```
|
```
|
||||||
/home/zulip/deployments/current/scripts/upgrade-zulip zulip-server-VERSION.tar.gz
|
/home/zulip/deployments/current/scripts/upgrade-zulip zulip-server-VERSION.tar.gz
|
||||||
```
|
```
|
||||||
Be sure to download to a path readable by the Zulip user (see
|
|
||||||
https://github.com/zulip/zulip/issues/208 for details on this
|
|
||||||
issue) but then run the upgrade as root.
|
|
||||||
|
|
||||||
The upgrade process will shut down the service, run `apt-get
|
The upgrade process will shut down the service, run `apt-get
|
||||||
upgrade`, a puppet apply, and any database migrations, and then
|
upgrade`, a puppet apply, and any database migrations, and then
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
TARBALL_ARCHIVE_PATH="/home/zulip/archives"
|
||||||
os.environ["PYTHONUNBUFFERED"] = "y"
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
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
|
mkdir_p, su_to_zulip
|
||||||
|
|
||||||
logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s",
|
logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s",
|
||||||
level=logging.INFO)
|
level=logging.INFO)
|
||||||
@@ -46,9 +48,20 @@ if not got_lock:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
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,))
|
||||||
|
mkdir_p(TARBALL_ARCHIVE_PATH)
|
||||||
|
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")
|
logging.info("Unpacking the tarball")
|
||||||
unpack_zulip = os.path.realpath(os.path.join(os.path.dirname(__file__), 'unpack-zulip'))
|
unpack_zulip = os.path.realpath(os.path.join(os.path.dirname(__file__), 'unpack-zulip'))
|
||||||
deploy_path = subprocess.check_output([unpack_zulip, tarball_path], preexec_fn=su_to_zulip)
|
deploy_path = subprocess.check_output([unpack_zulip, archived_tarball_path],
|
||||||
|
preexec_fn=su_to_zulip)
|
||||||
|
|
||||||
# Chdir to deploy_path and then run upgrade-zulip-stage-2 from the
|
# 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
|
# new version of Zulip (having the upgrade logic run from the new
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
@@ -29,3 +30,13 @@ if __name__ == '__main__':
|
|||||||
cmd = sys.argv[1]
|
cmd = sys.argv[1]
|
||||||
if cmd == 'make_deploy_path':
|
if cmd == 'make_deploy_path':
|
||||||
print(make_deploy_path())
|
print(make_deploy_path())
|
||||||
|
|
||||||
|
def mkdir_p(path):
|
||||||
|
# Python doesn't have an analog to `mkdir -p` < Python 3.2.
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except OSError, e:
|
||||||
|
if e.errno == errno.EEXIST and os.path.isdir(path):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|||||||
Reference in New Issue
Block a user