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:
Tim Abbott 2016-01-10 11:36:38 -08:00
parent c101bf663d
commit f871090bb6
3 changed files with 27 additions and 7 deletions

View File

@ -343,14 +343,10 @@ upgrade.
* To upgrade to a new version of the zulip server, download the
appropriate release tarball from
https://www.zulip.com/dist/releases/ to a path readable by the zulip
user (e.g. /home/zulip), and then run as root:
https://www.zulip.com/dist/releases/ and then run as root:
```
/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
upgrade`, a puppet apply, and any database migrations, and then

View File

@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
import os
import shutil
import sys
import subprocess
import logging
import shutil
import time
TARBALL_ARCHIVE_PATH="/home/zulip/archives"
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
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",
level=logging.INFO)
@ -46,9 +48,20 @@ if not got_lock:
sys.exit(1)
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")
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
# new version of Zulip (having the upgrade logic run from the new

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2.7
from __future__ import print_function
import errno
import os
import sys
import datetime
@ -29,3 +30,13 @@ if __name__ == '__main__':
cmd = sys.argv[1]
if cmd == '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