Restructure "shared" folder.

shared/seafile => contains ccnet/seafile-data/conf etc.
shared/db      => contains mysql data
shared/ssl     => letsencrypt certs
shared/logs/seafile => ccnet/seafile/seahub logs
shared/logs/var-log => mounted as /var/log in the container
This commit is contained in:
Shuai Lin 2016-11-12 14:03:52 +08:00
parent ad97dd85c1
commit c64dbb972d
6 changed files with 23 additions and 21 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()