seafile-containerized/launcher
Shuai Lin c64dbb972d 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
2016-11-12 14:03:52 +08:00

84 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
set -e
set -o pipefail
version=6.0.5
image=seafileorg/server:$version
dockerdir=$(cd $(dirname $0); pwd -P)
sharedir=$dockerdir/shared
installdir=/opt/seafile/seafile-server-$version
cd $dockerdir
dbg() {
if [[ $debug == "true" ]]; then
echo "dbg: $1"
fi
}
err_and_quit () {
printf "\n\n\033[33mError: %s\033[m\n\n" "$1"
exit 1
}
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
$sharedir/logs/var-log:/var/log
$dockerdir/bootstrap:/bootstrap:ro
$dockerdir/scripts:/scripts:ro
$dockerdir/scripts/tmp/check_init_admin.py:$installdir/check_init_admin.py:ro
$sharedir/.bash_history:/root/.bash_history
)
volumes=""
local m
for m in ${mounts[*]}; do
volumes="$volumes -v $m"
done
}
bootstrap() {
set_volumes
docker run --rm -it -e SEAFILE_BOOTSRAP=1 $volumes $image /scripts/bootstrap.py
}
start() {
set_volumes
docker run --rm -it $volumes $image /scripts/start.py
}
enter() {
err_and_quit "Not implemented yet"
}
function main {
local action
while [[ $# -gt 0 ]]
do
case "$1" in
bootstrap|start|enter) action=$1 ; shift 1 ;;
--debug) debug=true ; shift 1 ;;
--dummy) dummy=$2 ; shift 2 ;;
*) err_and_quit "Argument error. Please see help." ;;
esac
done
"$action"
}
main "$@"