2021-01-22 21:27:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-26 21:42:14 +00:00
|
|
|
function sigterm {
|
|
|
|
stop_socat
|
|
|
|
stop_server
|
|
|
|
exit 0
|
|
|
|
}
|
2021-01-22 21:27:05 +00:00
|
|
|
|
2021-01-26 21:42:14 +00:00
|
|
|
function start_server {
|
|
|
|
/scripts/create_data_links.sh
|
|
|
|
python3 /scripts/start.py
|
|
|
|
}
|
2021-01-22 21:27:05 +00:00
|
|
|
|
2021-01-26 21:42:14 +00:00
|
|
|
function stop_server {
|
|
|
|
echo "Stopping seafile server..."
|
|
|
|
/opt/seafile/seafile-server-latest/seafile.sh stop
|
|
|
|
}
|
2021-01-22 22:33:28 +00:00
|
|
|
|
2021-01-26 21:42:14 +00:00
|
|
|
function start_socat {
|
2021-01-27 23:40:00 +00:00
|
|
|
echo "Waiting for SeaRPC socket..."
|
2021-01-26 21:42:14 +00:00
|
|
|
while [ ! -S /opt/seafile/seafile-server-latest/runtime/seafile.sock ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
socat -d -d TCP-LISTEN:8001,fork,reuseaddr UNIX:/opt/seafile/seafile-server-latest/runtime/seafile.sock,forever
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_socat {
|
|
|
|
echo "Stopping socat..."
|
2021-01-27 15:28:51 +00:00
|
|
|
ps aux | grep '[s]ocat' | awk '{print $2}' | xargs kill -15 |& tee /dev/null
|
|
|
|
sleep 5
|
|
|
|
ps aux | grep '[s]ocat' | awk '{print $2}' | xargs kill -9 |& tee /dev/null
|
2021-01-26 21:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function keep_running {
|
|
|
|
while true; do
|
|
|
|
tail -f /dev/null & wait ${!}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'sigterm' SIGTERM
|
|
|
|
start_server &
|
|
|
|
start_socat &
|
|
|
|
keep_running
|