#!/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 if [[ ! -L /etc/nginx/sites-enabled/default ]]; then ln -s /opt/seafile/conf/nginx.conf /etc/nginx/sites-enabled/default nginx -s reload fi 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