seafile-containerized/seafile/scripts/enterpoint.sh

43 lines
770 B
Bash
Raw Normal View History

2020-07-16 07:14:10 +00:00
#!/bin/bash
# log function
function log() {
local time=$(date +"%F %T")
echo "$time $1 "
echo "[$time] $1 " &>> /opt/seafile/logs/enterpoint.log
}
# check nginx
while [ 1 ]; do
process_num=$(ps -ef | grep "/usr/sbin/nginx" | grep -v "grep" | wc -l)
if [ $process_num -eq 0 ]; then
log "Waiting Nginx"
sleep 0.2
else
log "Nginx ready"
break
fi
done
2020-07-21 05:49:04 +00:00
if [[ ! -L /etc/nginx/sites-enabled/default ]]; then
ln -s /opt/seafile/conf/nginx.conf /etc/nginx/sites-enabled/default
nginx -s reload
fi
2020-07-16 07:14:10 +00:00
log "This is a idle script (infinite loop) to keep container running."
function cleanup() {
kill -s SIGTERM $!
exit 0
}
trap cleanup SIGINT SIGTERM
while [ 1 ]; do
sleep 60 &
wait $!
done