mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 09:01:38 +00:00
2c5dace56e
TODO: add a cron job to renew the certs
100 lines
2.2 KiB
Bash
Executable file
100 lines
2.2 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_ports() {
|
|
ports="-p 80:80 -p 443:443"
|
|
ports=""
|
|
}
|
|
|
|
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
|
|
set_ports
|
|
docker run --rm -it --name seafile-bootstrap -e SEAFILE_BOOTSRAP=1 $volumes $ports $image /sbin/my_init -- /scripts/bootstrap.py
|
|
}
|
|
|
|
start() {
|
|
set_volumes
|
|
set_ports
|
|
docker run --rm -it --name seafile $volumes $ports $image \
|
|
/sbin/my_init -- /scripts/start.py
|
|
# /sbin/my_init -- bash -l
|
|
}
|
|
|
|
enter() {
|
|
err_and_quit "Not implemented yet"
|
|
}
|
|
|
|
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 "$@"
|