<commit_before>#!/bin/bash

#
# edit this
#

# the email we will send the mysql password to
USR_EMAIL=""

# can be replaced with the hostname you want to use instead of the ovh default one
# be sure that it has been declared in your dns zone
HOST_NAME="$(hostname)"

# mailgun domain credentials (create an account here: http://www.mailgun.com/)
SMTP_LOGIN=""
SMTP_PASS=""
SMTP_HOST="smtp.mailgun.org"

# the passphrase to generate your ssh key
SSH_PASSPHRASE=""

## =======================================================================================
##
## nothing to do below, just run the script and... voilà!
##
## =======================================================================================

##
## var automatically filed
##

USR_IP="${SSH_CLIENT%% *}"
MYSQL_PASSWORD=$(openssl rand -base64 8)

##
## Are you root?
##

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

##
## Do I have all the necessary infos?
##

if [ "$USR_EMAIL" = "" ]; then
   echo "Some data are missing, please give me your email at the beginning of the script" 1>&2
   exit 1
fi

##
## functions
##

log ()
{
	clear
	sleep 1
	echo  ":: $1"
	sleep 4
}

##
## init and basic tools
##

export LC_ALL=C
apt-get update && apt-get upgrade --yes
apt-get install --yes git curl mlocate dnsutils

hostname $HOST_NAME

##
## Makes terminal prettier
## 

curl https://gist.githubusercontent.com/zefranck/0a9f88c03b5a885c8cca9acfaed6fd11/raw/19717cbc619846cdc23bb679911accba98a12264/.bashrc > ~/.bashrc
source ~/.bashrc

##
## locales
##

locale-gen en_US.UTF-8 fr_FR.UTF-8

echo "" >> ~/.bashrc
echo "# Locales" >> ~/.bashrc
echo "export LANGUAGE=fr_FR.UTF-8" >> ~/.bashrc
echo "export LANG=fr_FR.UTF-8" >> ~/.bashrc
echo "export LC_ALL=C" >> ~/.bashrc
echo "" >> ~/.bashrc

source ~/.bashrc

##
## add iTerm integration //todo: if needed only//
## https://iterm2.com/

cd ~
curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash

##
## let's encrypt (cerbot)
##

echo "deb ftp://ftp.fr.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
apt-get update
apt-get install certbot -t --yes jessie-backports

##
## nginx 
##

log 'Installing secured nginx (thanx to https://www.nicolas-simond.com/)'

cd /tmp && wget --no-check-certificate https://raw.githubusercontent.com/stylersnico/nginx-openssl-chacha/master/build.sh && chmod +x build.sh && ./build.sh

mkdir /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ -p
curl https://gist.githubusercontent.com/zefranck/0a9f88c03b5a885c8cca9acfaed6fd11/raw/07c81dc718831f4c5b5a403320e3b7a3474e7bd0/default%2520nginx%2520vhost > /etc/nginx/sites-available/default
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/

chsh -s /bin/bash www-data

install -d -o www-data -g www-data -m 755 /var/www/vhosts
install -d -o www-data -g www-data -m 755 /var/www/vhosts/html
install -d -o www-data -g www-data -m 755 /var/www/.ssh/
cp /root/.bashrc /var/www/ 

chown www-data:www-data /var/www -R
su -c "cd ~ && curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash" www-data

##
## php
## apt-cache search php7-*
##

log 'Installing php 7 and composer'

echo "deb http://packages.dotdeb.org jessie all" > /etc/apt/sources.list.d/dotdeb.list
wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add -

apt-get update

apt-get install -y \
	php7.0-cli php7.0-curl php7.0-dev php7.0-zip php7.0-fpm \
	php7.0-gd php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-mbstring php7.0-opcache php7.0-memcache php7.0-mongo

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

##
## let's make ngninx and php work together
##

log 'Configuring nginx and php together'

#below is useless: https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
#sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini

sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php/7.0/fpm/pool.d/www.conf

# get default website
curl https://gist.githubusercontent.com/zefranck/0a9f88c03b5a885c8cca9acfaed6fd11/raw/5a2891378d2a7239366b22e1a1805770e0fc6303/default%2520nginx%2520host > /etc/nginx/sites-available/default

## create default page<commit_msg>fix external paths<commit_after>#!/bin/bash

#
# edit this
#

# the email we will send the mysql password to
USR_EMAIL=""

# can be replaced with the hostname you want to use instead of the ovh default one
# be sure that it has been declared in your dns zone
HOST_NAME="$(hostname)"

# mailgun domain credentials (create an account here: http://www.mailgun.com/)
SMTP_LOGIN=""
SMTP_PASS=""
SMTP_HOST="smtp.mailgun.org"

# the passphrase to generate your ssh key
SSH_PASSPHRASE=""

## =======================================================================================
##
## nothing to do below, just run the script and... voilà!
##
## =======================================================================================

##
## var automatically filed
##

USR_IP="${SSH_CLIENT%% *}"
MYSQL_PASSWORD=$(openssl rand -base64 8)

##
## Are you root?
##

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

##
## Do I have all the necessary infos?
##

if [ "$USR_EMAIL" = "" ]; then
   echo "Some data are missing, please give me your email at the beginning of the script" 1>&2
   exit 1
fi

##
## functions
##

log ()
{
	clear
	sleep 1
	echo  ":: $1"
	sleep 4
}

##
## init and basic tools
##

export LC_ALL=C
apt-get update && apt-get upgrade --yes
apt-get install --yes git curl mlocate dnsutils

hostname $HOST_NAME

##
## Makes terminal prettier
## 

curl https://raw.githubusercontent.com/zefranck/debian-ovh-vps/master/.bashrc > ~/.bashrc
source ~/.bashrc

##
## locales
##

locale-gen en_US.UTF-8 fr_FR.UTF-8

echo "" >> ~/.bashrc
echo "# Locales" >> ~/.bashrc
echo "export LANGUAGE=fr_FR.UTF-8" >> ~/.bashrc
echo "export LANG=fr_FR.UTF-8" >> ~/.bashrc
echo "export LC_ALL=C" >> ~/.bashrc
echo "" >> ~/.bashrc

source ~/.bashrc

##
## add iTerm integration //todo: if needed only//
## https://iterm2.com/

cd ~
curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash

##
## let's encrypt (cerbot)
##

echo "deb ftp://ftp.fr.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
apt-get update
apt-get install certbot -t --yes jessie-backports

##
## nginx 
##

log 'Installing secured nginx (thanx to https://www.nicolas-simond.com/)'

cd /tmp && wget --no-check-certificate https://raw.githubusercontent.com/stylersnico/nginx-openssl-chacha/master/build.sh && chmod +x build.sh && ./build.sh

mkdir /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ -p
curl https://raw.githubusercontent.com/zefranck/debian-ovh-vps/master/nginx/sites-available/default > /etc/nginx/sites-available/default
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/

chsh -s /bin/bash www-data

install -d -o www-data -g www-data -m 755 /var/www/vhosts
install -d -o www-data -g www-data -m 755 /var/www/vhosts/html
install -d -o www-data -g www-data -m 755 /var/www/.ssh/
cp /root/.bashrc /var/www/ 

chown www-data:www-data /var/www -R
su -c "cd ~ && curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash" www-data

##
## php
## apt-cache search php7-*
##

log 'Installing php 7 and composer'

echo "deb http://packages.dotdeb.org jessie all" > /etc/apt/sources.list.d/dotdeb.list
wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add -

apt-get update

apt-get install -y \
	php7.0-cli php7.0-curl php7.0-dev php7.0-zip php7.0-fpm \
	php7.0-gd php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-mbstring php7.0-opcache php7.0-memcache php7.0-mongo

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

##
## let's make ngninx and php work together
##

log 'Configuring nginx and php together'

#below is useless: https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
#sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini

sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php/7.0/fpm/pool.d/www.conf

## create default page
{'fraction_non_alphanumeric': 0.19433892905281216, 'fraction_numerical': 0.035657394927092266, 'mean_word_length': 3.7425915165601396, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 42, 'https://': 21, 'lorem ipsum': 0, 'www.': 40, 'xml': 2}, 'pii_count': 2, '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': '6379883', 'n_tokens_mistral': 3370, 'n_tokens_neox': 3082, 'n_words': 745}