handle existing install
This commit is contained in:
parent
e72eb4b31f
commit
9a62f2bc5e
@ -37,6 +37,14 @@ def list_command(page="https://www.seafile.com/en/download/"):
|
|||||||
def current_version_command():
|
def current_version_command():
|
||||||
print(current_version())
|
print(current_version())
|
||||||
|
|
||||||
|
def installed_versions():
|
||||||
|
installed = []
|
||||||
|
for f in os.listdir(seaf_home):
|
||||||
|
m = re.findall(version_re,f)
|
||||||
|
if len(m) > 0:
|
||||||
|
installed.append(m[0])
|
||||||
|
return installed
|
||||||
|
|
||||||
def current_version():
|
def current_version():
|
||||||
current = os.path.realpath(os.path.join(seaf_home, "seafile-server-latest"))
|
current = os.path.realpath(os.path.join(seaf_home, "seafile-server-latest"))
|
||||||
res = re.findall(version_re,current)
|
res = re.findall(version_re,current)
|
||||||
@ -80,6 +88,7 @@ def install_command(url):
|
|||||||
if not os.path.exists(dest):
|
if not os.path.exists(dest):
|
||||||
shutil.move(os.path.join(tmp,f), dest)
|
shutil.move(os.path.join(tmp,f), dest)
|
||||||
else:
|
else:
|
||||||
|
shutil.rmtree(tmp)
|
||||||
print("Found previous installation, resuming setup")
|
print("Found previous installation, resuming setup")
|
||||||
current = current_version()
|
current = current_version()
|
||||||
target_version = ''.join(re.findall(version_re,dest))
|
target_version = ''.join(re.findall(version_re,dest))
|
||||||
@ -87,7 +96,7 @@ def install_command(url):
|
|||||||
else: current = "0.0.0"
|
else: current = "0.0.0"
|
||||||
print("Upgrading from: %s -> %s" % (current, target_version))
|
print("Upgrading from: %s -> %s" % (current, target_version))
|
||||||
perform_upgrade_command(target_version,mysql=("SEAF_MYSQL" in os.environ and os.environ["SEAF_MYSQL"]))
|
perform_upgrade_command(target_version,mysql=("SEAF_MYSQL" in os.environ and os.environ["SEAF_MYSQL"]))
|
||||||
if len(os.listdir(tmp)) != 0:
|
if os.exists(tmp) and len(os.listdir(tmp)) != 0:
|
||||||
print("Failed to unpack update")
|
print("Failed to unpack update")
|
||||||
os.rmdir(tmp)
|
os.rmdir(tmp)
|
||||||
return 1
|
return 1
|
||||||
@ -106,6 +115,8 @@ def main_command(version="latest",page="https://www.seafile.com/en/download/"):
|
|||||||
if version_int(current_version()) == version_int(version):
|
if version_int(current_version()) == version_int(version):
|
||||||
print("%s(%s) is already installed" % (version,version_int(version)))
|
print("%s(%s) is already installed" % (version,version_int(version)))
|
||||||
return 1
|
return 1
|
||||||
|
if version in installed_versions():
|
||||||
|
return perform_upgrade_command(version)
|
||||||
if install:
|
if install:
|
||||||
print("Installing: %s" % version)
|
print("Installing: %s" % version)
|
||||||
return install_command(install)
|
return install_command(install)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user