File: //sbin/init-scripts/prestart/nginx-config.sh
#!/bin/bash
if [[ "$X_APPLICATION_HTTP_SERVER" != "nginx" ]]; then
exit 0
fi
HOME_DIR=/var/www/html/
UID_GID=$(stat -c "%u:%g" "$HOME_DIR")
if [ ! -d $HOME_DIR/nginx-conf ]; then
mkdir -p $HOME_DIR/nginx-conf/conf.d/
mkdir $HOME_DIR/nginx-conf/default.d/
cp "/etc/nginx/conf.d/default.tmpl" "$HOME_DIR/nginx-conf/nginx.conf.model"
cp "/etc/nginx/mime.types" "$HOME_DIR/nginx-conf/"
chmod -R 644 $HOME_DIR/nginx-conf
chmod 755 $HOME_DIR/nginx-conf
chown -R "$UID_GID" $HOME_DIR/nginx-conf
fi
if [ -d /var/lib/nginx ]; then
chown -R "$UID_GID" /var/lib/nginx;
fi
if [ ! -f $HOME_DIR/nginx-conf/*.conf ]; then
cp "/etc/nginx/conf.d/default.tmpl" "$HOME_DIR/nginx-conf/nginx.conf"
chown "$UID_GID" $HOME_DIR/nginx-conf/nginx.conf
fi
if $(grep -q "/var/www/html/nginx-conf/mime.types" $HOME_DIR/nginx-conf/*.conf -r); then
if [ ! -f $HOME_DIR/nginx-conf/mime.types ]; then
cp "/etc/nginx/mime.types" "$HOME_DIR/nginx-conf/"
chown "$UID_GID" "$HOME_DIR/nginx-conf/mime.types"
fi
fi
exit 0