mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2025-02-22 21:12:16 +00:00
Add a version stamp file seafile-data/current_version.
This commit is contained in:
parent
42c7be4c05
commit
a64c9b83e4
|
@ -18,7 +18,7 @@ import time
|
|||
from utils import (
|
||||
call, get_conf, get_install_dir, show_progress,
|
||||
get_script, render_template, get_seafile_version, eprint,
|
||||
cert_has_valid_days
|
||||
cert_has_valid_days, get_version_stamp_file, update_version_stamp
|
||||
)
|
||||
|
||||
seafile_version = get_seafile_version()
|
||||
|
@ -117,7 +117,10 @@ def do_parse_ports():
|
|||
sys.stdout.flush()
|
||||
|
||||
def init_seafile_server():
|
||||
version_stamp_file = get_version_stamp_file()
|
||||
if exists(join(shared_seafiledir, 'seafile-data')):
|
||||
if not exists(version_stamp_file):
|
||||
update_version_stamp(version_stamp_file, os.environ['SEAFILE_VERSION'])
|
||||
show_progress('Skip running setup-seafile-mysql.py because there is existing seafile-data folder.')
|
||||
return
|
||||
|
||||
|
@ -153,6 +156,8 @@ def init_seafile_server():
|
|||
if not exists(dst) and exists(src):
|
||||
shutil.move(src, shared_seafiledir)
|
||||
|
||||
update_version_stamp(version_stamp_file, os.environ['SEAFILE_VERSION'])
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args.parse_ports:
|
||||
|
|
|
@ -247,3 +247,15 @@ def cert_has_valid_days(cert, days):
|
|||
secs = 86400 * int(days)
|
||||
retcode = call('openssl x509 -checkend {} -noout -in {}'.format(secs, cert), check_call=False)
|
||||
return retcode == 0
|
||||
|
||||
def get_version_stamp_file():
|
||||
return '/shared/seafile/seafile-data/current_version'
|
||||
|
||||
def read_version_stamp(fn):
|
||||
assert exists(fn), 'version stamp file {} does not exist!'.format(fn)
|
||||
with open(fn, 'r') as fp:
|
||||
return fp.read().strip()
|
||||
|
||||
def update_version_stamp(fn, version):
|
||||
with open(fn, 'w') as fp:
|
||||
fp.write(version + '\n')
|
||||
|
|
Loading…
Reference in a new issue