2021-01-22 21:22:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-31 13:50:13 +00:00
|
|
|
function init_seahub {
|
2021-01-27 23:39:18 +00:00
|
|
|
/scripts/create_data_links.sh
|
2021-01-31 13:56:03 +00:00
|
|
|
echo "{ \"email\": \"${SEAFILE_ADMIN_EMAIL}\",\"password\": \"${SEAFILE_ADMIN_PASSWORD}\"}" >/opt/seafile/conf/admin.txt
|
2021-01-27 23:39:18 +00:00
|
|
|
python3 /opt/seafile/seafile-server-latest/check_init_admin.py
|
2021-01-31 13:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function start_seahub {
|
|
|
|
echo "Starting seahub..."
|
2021-01-27 23:39:18 +00:00
|
|
|
python3 /opt/seafile/seafile-server-latest/seahub/manage.py runserver 0.0.0.0:8000
|
|
|
|
}
|
2021-01-22 21:22:53 +00:00
|
|
|
|
2021-01-27 23:39:18 +00:00
|
|
|
function start_socat {
|
|
|
|
mkdir -p /opt/seafile/seafile-server-latest/runtime
|
2021-02-01 17:16:11 +00:00
|
|
|
while ! nc -z seafile-server 8001 2>/dev/null; do
|
|
|
|
sleep 1
|
2021-01-31 13:50:13 +00:00
|
|
|
done
|
2021-02-01 17:16:11 +00:00
|
|
|
echo "Starting socat..."
|
|
|
|
socat -d -d UNIX-LISTEN:/opt/seafile/seafile-server-latest/runtime/seafile.sock,fork TCP:seafile-server:8001,forever,keepalive,keepidle=10,keepintvl=10,keepcnt=2
|
2021-01-31 13:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function watch_server {
|
|
|
|
while true; do
|
2021-02-01 18:18:38 +00:00
|
|
|
sleep 2
|
|
|
|
if ! nc -z seafile-server 8082 2>/dev/null; then
|
2021-01-31 13:50:13 +00:00
|
|
|
echo "Seafile server is unreachable. Stopping seahub..."
|
|
|
|
pkill -f manage.py
|
2021-02-01 18:18:38 +00:00
|
|
|
while ! nc -z seafile-server 8082 2>/dev/null; do
|
2021-01-31 13:50:13 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
start_seahub &
|
|
|
|
fi
|
|
|
|
done
|
2021-01-27 23:39:18 +00:00
|
|
|
}
|
2021-01-22 21:22:53 +00:00
|
|
|
|
2021-01-27 23:39:18 +00:00
|
|
|
function keep_running {
|
|
|
|
while true; do
|
|
|
|
tail -f /dev/null & wait ${!}
|
|
|
|
done
|
|
|
|
}
|
2021-01-22 21:22:53 +00:00
|
|
|
|
2021-01-27 23:39:18 +00:00
|
|
|
start_socat &
|
2021-01-31 13:50:13 +00:00
|
|
|
init_seahub
|
2021-01-27 23:39:18 +00:00
|
|
|
start_seahub &
|
2021-01-31 13:50:13 +00:00
|
|
|
watch_server &
|
2021-01-27 23:39:18 +00:00
|
|
|
keep_running
|