diff --git a/.travis.yml b/.travis.yml index ba48e45..dfd6bd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,7 @@ install: - echo "Nothing to install" script: - - cd image && make base && make - - cd .. + - cd image && make base && make && cd .. - cp samples/server-sqlite3.conf bootstrap/bootstrap.conf - ./launcher bootstrap - ./launcher start diff --git a/image/seafile/Dockerfile b/image/seafile/Dockerfile index 2289380..3b4b415 100644 --- a/image/seafile/Dockerfile +++ b/image/seafile/Dockerfile @@ -5,7 +5,8 @@ ENV SEAFILE_VERSION=6.0.5 RUN mkdir -p /opt/seafile/ && \ curl -sSL -o - https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.5_x86-64.tar.gz \ - | tar xzf - -C /opt/seafile/ + | tar xzf - -C /opt/seafile/ && \ + ln -sf /opt/seafile/seafile-server-${SEAFILE_VERSION} /opt/seafile/seafile-server-latest RUN mkdir -p /etc/my_init.d ADD create_data_links.sh /etc/my_init.d/create_data_links.sh diff --git a/image/seafile/create_data_links.sh b/image/seafile/create_data_links.sh index fbb2193..386e517 100755 --- a/image/seafile/create_data_links.sh +++ b/image/seafile/create_data_links.sh @@ -10,19 +10,20 @@ fi dirs=( conf ccnet - logs seafile-data seahub-data seahub.db ) for d in ${dirs[*]}; do - src=/shared/$d + src=/shared/seafile/$d if [[ -e $src ]]; then ln -sf $src /opt/seafile/ fi done -ln -sf /opt/seafile/seafile-server-${SEAFILE_VERSION} /opt/seafile/seafile-server-latest +if [[ -e /shared/logs/seafile ]]; then + ln -sf /shared/logs/seafile/ /opt/seafile/logs +fi # TODO: create avatars link diff --git a/launcher b/launcher index a233ef8..dd06fac 100755 --- a/launcher +++ b/launcher @@ -22,18 +22,20 @@ err_and_quit () { exit 1 } -set_volumes() { - local mounts seahub_db - - seahub_db=$sharedir/seahub.db - if [[ ! -e $seahub_db ]]; then - touch $seahub_db - fi +init_shared() { + mkdir -p $sharedir/seafile/ + mkdir -p $sharedir/logs/{seafile,var-log} + touch $sharedir/logs/var-log/syslog local bash_history=$sharedir/.bash_history if [[ ! -e $bash_history ]]; then touch $bash_history fi +} + +set_volumes() { + local mounts + init_shared mounts=( $sharedir:/shared @@ -41,7 +43,7 @@ set_volumes() { $dockerdir/bootstrap:/bootstrap:ro $dockerdir/scripts:/scripts:ro $dockerdir/scripts/tmp/check_init_admin.py:$installdir/check_init_admin.py:ro - $bash_history:/root/.bash_history + $sharedir/.bash_history:/root/.bash_history ) volumes="" local m diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index b3e7a1d..659d35a 100755 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -16,8 +16,11 @@ from utils import call, get_conf, get_install_dir, get_script installdir = get_install_dir() topdir = dirname(installdir) +shared_seafiledir = '/shared/seafile' def main(): + if not exists(shared_seafiledir): + os.mkdir(shared_seafiledir) env = { 'SERVER_NAME': 'seafile', 'SERVER_IP': get_conf("server.hostname"), @@ -25,13 +28,9 @@ def main(): call('{} auto'.format(get_script('setup-seafile.sh')), env=env) for fn in ('conf', 'ccnet', 'seafile-data', 'seahub-data', 'seahub.db'): src = join(topdir, fn) - dst = join('/shared', fn) - if exists(dst): - if isdir(dst): - shutil.rmtree(dst) - else: - os.unlink(dst) - shutil.move(src, '/shared') + dst = join(shared_seafiledir, fn) + if not exists(dst) and exists(src): + shutil.move(src, shared_seafiledir) if __name__ == '__main__': main() diff --git a/shared/logs/var-log/.gitkeep b/shared/.gitkeep similarity index 100% rename from shared/logs/var-log/.gitkeep rename to shared/.gitkeep