<commit_before>#!/bin/bash

#-- Configuration --#
NGINX='<%= node[:nginx][:dir] %>'
APP_NAME=$1
APP_DIR=$2/current
APP_DOMAINS=`echo $3 | sed 's/,/ /g'`
#-- Retrieve Proxy ip and port from package.json --#
if [ -f $APP_DIR/package.json ]
then
	APP_IP=`sed -n 's/[[:space:]]*"proxy"[[:space:]]*:[[:space:]]*"\([^"]*\).*/\1/p' $APP_DIR/package.json`
	APP_PORT=`sed -n 's/[[:space:]]*"port"[[:space:]]*:[[:space:]]*"\([^"]*\).*/\1/p' $APP_DIR/package.json`
fi


#-- Available Proxy Website --#
if [ -n "$APP_DOMAINS" ] && [ -n "$APP_IP" ] && [ -n "$APP_PORT" ]
then     
	echo ""> $NGINX/sites-enabled/$APP_NAME.conf

	DOMAINS=$(echo $APP_DOMAINS | tr " " "\n")
	for DOMAIN in $DOMAINS
	do
		REDIR=`echo $DOMAIN | grep '^[^.]*\.[^.]*$'`
		if [ -n "$REDIR" ]
		then
			echo "server {
	server_name $REDIR;
	rewrite ^(.*) http://www.$REDIR\$1 permanent;
}">> $NGINX/sites-enabled/$APP_NAME.conf
		fi
	done

	echo "server {
	listen 80;
	server_name $APP_DOMAINS;
	location / {
		proxy_pass http://$APP_IP:$APP_PORT/;
	}
}">> $NGINX/sites-enabled/$APP_NAME.conf
fi<commit_msg>Rewrite domain.tld to www.domain.tld<commit_after>#!/bin/bash

#-- Configuration --#
NGINX='<%= node[:nginx][:dir] %>'
APP_NAME=$1
APP_DIR=$2/current
APP_DOMAINS=`echo $3 | sed 's/,/ /g'`
#-- Retrieve Proxy ip and port from package.json --#
if [ -f $APP_DIR/package.json ]
then
	APP_IP=`sed -n 's/[[:space:]]*"proxy"[[:space:]]*:[[:space:]]*"\([^"]*\).*/\1/p' $APP_DIR/package.json`
	APP_PORT=`sed -n 's/[[:space:]]*"port"[[:space:]]*:[[:space:]]*"\([^"]*\).*/\1/p' $APP_DIR/package.json`
fi


#-- Available Proxy Website --#
if [ -n "$APP_DOMAINS" ] && [ -n "$APP_IP" ] && [ -n "$APP_PORT" ]
then     
	echo ""> $NGINX/sites-enabled/$APP_NAME.conf
	SERVERNAMES=""

	DOMAINS=$(echo $APP_DOMAINS | tr " " "\n")
	for DOMAIN in $DOMAINS
	do
		REDIR=`echo $DOMAIN | grep '^[^.]*\.[^.]*$'`
		if [ -n "$REDIR" ]
		then
			echo "server {
	server_name $REDIR;
	rewrite ^(.*) http://www.$REDIR\$1 permanent;
}

">> $NGINX/sites-enabled/$APP_NAME.conf
		fi
		
		REDIR2=`echo $DOMAIN | grep '^[^.]*\.[^.]*\.[^.]*$'`
		if [ -n "$REDIR2" ]
		then
			SERVERNAMES="$SERVERNAMES $REDIR2"
		fi		
	done

	if [ -n "$SERVERNAMES" ]
	then
		echo "server {
	listen 80;
	server_name $APP_DOMAINS;
	location / {
		proxy_pass http://$APP_IP:$APP_PORT/;
	}
}">> $NGINX/sites-enabled/$APP_NAME.conf
	fi
fi
{'fraction_non_alphanumeric': 0.263000852514919, 'fraction_numerical': 0.008098891730605285, 'mean_word_length': 3.6291913214990137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7544940', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1030, 'n_words': 180}