#!/bin/sh
# Generate copy host mount files for the first time
if [[ ! -e /custom/conf/nginx.conf ]]; then
    echo "Copy config file (nginx.conf)..."
    cp -f /etc/nginx/nginx.conf /custom/conf/nginx.conf
    chmod 0600 /custom/conf/nginx.conf
else
	cp -f /custom/conf/nginx.conf /etc/nginx/nginx.conf
fi

if [[ ! -e /custom/conf/default.conf ]]; then
    echo "Copy config file (default.conf)..."
    cp -f /etc/nginx/conf.d/default.conf /custom/conf/default.conf
    chmod 0600 /custom/conf/default.conf
else
    cd /custom/conf
    cp -f `ls |grep .conf$ | grep -v nginx.conf` /etc/nginx/conf.d/
	#cp -f /custom/conf/default.conf /etc/nginx/conf.d/default.conf
fi

# Wait for SIGTERM
#wait

