Merge branch 'master' into alpine
This commit is contained in:
commit
fe1b40da97
@ -78,9 +78,24 @@ def perform_upgrade_command(version,mysql=False,yes=True):
|
||||
cmd.append(script)
|
||||
call(["/bin/sh", "-c", ''.join(cmd)], stdout=sys.stdout, stdin=(None if yes else sys.stdin))
|
||||
|
||||
def install_command(url):
|
||||
def download(url, version):
|
||||
tmp = tempfile.mkdtemp()
|
||||
if call(["/bin/sh", "-c", 'cd %s; curl %s | tar xzv' % (tmp, url)]) == 0:
|
||||
filename = "server_%s.tar.gz" % version
|
||||
dest = os.path.join(seaf_home, "pkg", filename)
|
||||
if os.path.exists(dest):
|
||||
return dest
|
||||
if call(["/bin/sh", "-c", 'curl %s --output %s/%s' % (url, tmp, filename)]) == 0:
|
||||
shutil.move(os.path.join(tmp,filename), dest)
|
||||
call(["/bin/chmod", "-w", dest])
|
||||
return dest
|
||||
else:
|
||||
print("Download failed")
|
||||
return 0
|
||||
|
||||
def install_command(url, version):
|
||||
pkg = download(url, version)
|
||||
tmp = tempfile.mkdtemp()
|
||||
if pkg and call(["/bin/sh", "-c", 'cd %s; tar xzvf %s' % (tmp, pkg)]) == 0:
|
||||
for f in os.listdir(tmp):
|
||||
dest = os.path.join(seaf_home, os.path.basename(f))
|
||||
if len(re.findall(version_re, f)) > 0:
|
||||
@ -95,7 +110,7 @@ def install_command(url):
|
||||
else: current = "0.0.0"
|
||||
print("Upgrading from: %s -> %s" % (current, target_version))
|
||||
perform_upgrade_command(target_version,mysql=("SEAF_MYSQL" in os.environ and os.environ["SEAF_MYSQL"]))
|
||||
if os.exists(tmp) and len(os.listdir(tmp)) != 0:
|
||||
if os.path.exists(tmp) and len(os.listdir(tmp)) != 0:
|
||||
print("Failed to unpack update")
|
||||
os.rmdir(tmp)
|
||||
return 1
|
||||
@ -118,7 +133,7 @@ def main_command(version="latest",page="https://www.seafile.com/en/download/"):
|
||||
return perform_upgrade_command(version)
|
||||
if install:
|
||||
print("Installing: %s" % version)
|
||||
sys.exit(install_command(install))
|
||||
sys.exit(install_command(install, version))
|
||||
else:
|
||||
print("Couldn't determine download for %s" % version)
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user