mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 09:01:38 +00:00
99d2c8456b
At this moment, we only support running mysql server inside the container. Support for running mysql(and memcached) in a separate container would be added later.
93 lines
2.1 KiB
Bash
Executable file
93 lines
2.1 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,db}
|
|
mkdir -p $sharedir/logs/{seafile,var-log}
|
|
|
|
mkdir -p $sharedir/logs/var-log/nginx
|
|
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
|
|
$sharedir/db:/var/lib/mysql
|
|
$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() {
|
|
local bootstrap_conf=$dockerdir/bootstrap/bootstrap.conf
|
|
if [[ ! -e $bootstrap_conf ]]; then
|
|
err_and_quit "The file $bootstrap_conf doesn't exist. Have you run seafile-server-setup?"
|
|
fi
|
|
set_volumes
|
|
docker run --rm -it -e SEAFILE_BOOTSRAP=1 $volumes $image /sbin/my_init -- /scripts/bootstrap.py
|
|
}
|
|
|
|
start() {
|
|
set_volumes
|
|
docker run --rm -it --name seafile $volumes $image \
|
|
/sbin/my_init -- /scripts/start.py
|
|
# /sbin/my_init -- bash -l
|
|
}
|
|
|
|
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 "$@"
|