Bladeren bron

Init commit

Andrea Pollastri 6 jaren geleden
bovenliggende
commit
07e3e2b046
9 gewijzigde bestanden met toevoegingen van 832 en 2 verwijderingen
  1. 41 2
      README.md
  2. 90 0
      alias-add.sh
  3. 43 0
      alias-del.sh
  4. 196 0
      go-16.sh
  5. 194 0
      go-18.sh
  6. 131 0
      host-add.sh
  7. 44 0
      host-del.sh
  8. 66 0
      passwd.sh
  9. 27 0
      ssl.sh

+ 41 - 2
README.md

@@ -1,2 +1,41 @@
-# cipi
-LAMP AUTO-DEPLOY ON LINUX UBUNTU SERVER
+# CIPI
+### LAMP AUTO-DEPLOY ON LINUX UBUNTU SERVER
+Install PHP 7.2, MySql 5.7, phpmyadmin, Let's encrypt, fail2ban and other on an empty Linux Ubuntu VPS.
+
+More info on [https://cipi.io](https://cipi.io)
+
+#### Ubuntu 16.04 Version Installation
+Run it as root on an empty Linux Ubuntu 16.04 server:
+> wget -O - https://raw.githubusercontent.com/andreapollastri/cipi/master/go-16.sh | bash
+
+#### Ubuntu 18.04 Version Installation
+Run it as root on an empty Linux Ubuntu 18.04 server:
+> wget -O - https://raw.githubusercontent.com/andreapollastri/cipi/master/go-18.sh | bash
+
+#### Create a Virtual host
+To create a virtual host:
+> sudo sh /cipi/host-add.sh -d DOMAIN.EXT
+
+This script generates one SFTP/SSH user, one document root, one SSL certificate, one MySql DB and one MySql user for DOMAIN and WWW.DOMAIN.
+
+#### Delete a Virtual host
+To remove a virtual host (and its user)
+> sudo sh /cipi/host-del.sh -u HOSTUSER
+
+#### Create an Alias
+To create an alias pointed to an user document root:
+> sudo sh /cipi/alias-add.sh -d DOMAIN.EXT -u HOSTUSER
+
+#### Delete an Alias
+To create an alias pointed to an user document root:
+> sudo sh /cipi/alias-del.sh -a ALIASCODE -u ALIASHOSTUSER
+
+#### Regenerate an SSL certificate
+To regenerate an SSL certificate:
+> sudo sh /cipi/ssl.sh -d DOMAIN.EXT
+
+#### Change user SFTP/SSH and DB passwords
+To regenerate an SSL certificate:
+> sudo sh /cipi/passwd.sh -u HOSTUSER
+
+## Enjoy :)

+ 90 - 0
alias-add.sh

@@ -0,0 +1,90 @@
+#!/usr/bin/env bash
+
+USER_NAME=
+DOMAIN=
+
+# Check if user is root
+if [ $(id -u) != "0" ]; then
+    echo "Error: You must be root to run this script."
+    exit 1
+fi
+
+while [ -n "$1" ] ; do
+            case $1 in
+            -d | --domain )
+                    shift
+                    DOMAIN=$1
+                    ;;
+            -u | --user )
+                    shift
+                    USER_NAME=$1
+                    ;;                                                                
+            * )
+                    echo "ERROR: Unknown option: $1"
+                    exit -1
+                    ;;
+            esac
+            shift
+done
+
+ALIAS=$(cat /dev/urandom | tr -dc '0-9' | fold -w 8 | head -n 1)
+CONF=/etc/apache2/sites-available/$USER_NAME$ALIAS.conf
+touch $CONF
+
+cat > "$CONF" <<EOF
+<VirtualHost $DOMAIN:80>
+	ServerName $DOMAIN
+        ServerAdmin webmaster@localhost
+        DocumentRoot /home/$USER_NAME/web
+        <Directory />
+                Order allow,deny
+				Options FollowSymLinks
+				Allow from all
+				AllowOverRide All
+				Require all granted
+                SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /home/$USER_NAME/web>
+				Order allow,deny
+				Options FollowSymLinks
+				Allow from all
+				AllowOverRide All
+				Require all granted
+                SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+
+#RESTART
+a2ensite $USER_NAME$ALIAS.conf
+service apache2 reload
+
+#SSL CERTIFICATE
+certbot --apache -d $DOMAIN --non-interactive --agree-tos --email admin@admin.com
+CRON=/cipi/certbot_renew_$USER_NAME$ALIAS.sh
+touch $CRON
+cat > "$CRON" <<EOF
+sudo certbot certonly --noninteractive --apache --agree-tos --email admin@admin.com --d $DOMAIN --post-hook "service apache2 reload"
+EOF
+TASK=/etc/cron.d/certbot_renew_$USER_NAME$ALIAS.crontab
+touch $TASK
+cat > "$TASK" <<EOF
+0 1 * * * $USER_NAME /cipi/certbot_renew_$USER_NAME$ALIAS.sh
+EOF
+crontab /etc/cron.d/certbot_renew_$USER_NAME$ALIAS.crontab
+
+#RESUME
+clear
+echo "###################################################################################"
+echo "                              INSTALLATION COMPLETE "
+echo "###################################################################################"
+echo ""
+echo "Alias: $DOMAIN"
+echo "Alias Code: $ALIAS"
+echo "Alias User: $USER_NAME"
+echo "Document Root: /home/$USER_NAME/web/"
+echo ""
+echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+echo ""
+echo "###################################################################################"
+echo ""

+ 43 - 0
alias-del.sh

@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+ALIAS=
+USER_NAME=
+
+# Check if user is root
+if [ $(id -u) != "0" ]; then
+    echo "Error: You must be root to run this script."
+    exit 1
+fi
+
+while [ -n "$1" ] ; do
+            case $1 in
+            -a | --alias )
+                    shift
+                    ALIAS=$1
+                    ;;
+            -u | --user )
+                    shift
+                    USER_NAME=$1
+                    ;;                                                                
+            * )
+                    echo "ERROR: Unknown option: $1"
+                    exit -1
+                    ;;
+            esac
+            shift
+done
+
+#SSL CERTIFICATE
+unlink /cipi/certbot_renew_$USER_NAME$ALIAS.sh
+unlink /etc/cron.d/certbot_renew_$USER_NAME$ALIAS.crontab
+
+#APACHE
+a2dissite $USER_NAME$ALIAS.conf
+
+#RESTART
+service apache2 reload
+
+echo "###################################################################################"
+echo "                               DELETE COMPLETE "
+echo "###################################################################################"
+echo ""

+ 196 - 0
go-16.sh

@@ -0,0 +1,196 @@
+#!/bin/bash
+
+#START
+echo "###################################################################################"
+echo "Please be Patient: Installation will start now....... It may take some time :)"
+echo "###################################################################################"
+echo -e "\n"
+
+#VARS
+IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
+USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
+PASS=$(openssl rand -base64 32)
+DBPASS=$(openssl rand -base64 32)
+
+#CIPI CORE
+mkdir /cipi/
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/host-add.sh -O /cipi/host-add.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/host-del.sh -O /cipi/host-del.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/ssl.sh -O /cipi/ssl.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/passwd.sh -O /cipi/passwd.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/alias-add.sh -O /cipi/alias-add.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/alias-del.sh -O /cipi/alias-del.sh
+DBRFILE=/cipi/DBR
+touch $DBRFILE
+cat > "$DBRFILE" <<EOF
+$DBPASS
+EOF
+sudo chmod o-r /cipi
+
+#ALIAS
+shopt -s expand_aliases
+alias ll='ls -alF'
+
+#NEWROOT USER
+sudo useradd -m -s /bin/bash $USER
+echo "$USER:$PASS"|chpasswd
+usermod -aG sudo $USER
+
+#PHP7 PPA
+sudo apt-get -y install python-software-properties
+sudo add-apt-repository -y ppa:ondrej/php
+
+#REPO UPDATES
+sudo apt-get update
+
+#LAMP INSTALLATION
+sudo apt-get -y install rpl fail2ban openssl apache2 php7.2 php7.2-common php7.2-cli php7.2-fpm php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml libmcrypt-dev mysql-client
+
+#FIREWALL
+sudo ufw --force-enable reset
+
+#MYSQL INSTALLATION AND PASSWORD SET
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASS"
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASS"
+sudo apt-get -y install mysql-server
+
+#SERVICE RESTART AND CONFIGURATION FIXING
+echo -e "\n"
+sudo a2enmod rewrite
+echo -e "\n"
+sudo a2enmod proxy_fcgi setenvif
+echo -e "\n"
+sudo a2enconf php7.2-fpm
+echo -e "\n"
+sudo rpl -i -w "AllowOverride None" "AllowOverride All" /etc/apache2/apache2.conf
+echo -e "\n"
+sudo service apache2 restart && apache2 reload && service mysql restart > /dev/null
+echo -e "\n"
+php -v
+if [ $? -ne 0 ]; then
+   echo "Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)"
+else
+   echo "Installed Services run $(tput bold)$(tput setaf 2)Sucessfully$(tput sgr0)"
+fi
+
+#PHPMYADMIN INSTALLATION
+set -euo pipefail
+IFS=$'\n\t'
+sudo add-apt-repository -y ppa:nijel/phpmyadmin
+sudo apt-get update
+sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
+sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $DBPASS"
+sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASS"
+sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $DBPASS"
+sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"
+sudo apt-get -y install phpmyadmin
+sudo service apache2 restart
+sudo apt-get clean
+
+#DEFAULT VIRTUALHOST
+sudo rm -rf /var/www/html/
+sudo mkdir /var/www/html/
+BASE=/var/www/html/index.html
+touch $BASE
+cat > "$BASE" <<EOF
+<title>It works!</title><br><br>
+<center><h1>It works!</h1></center>
+EOF
+sudo service apache2 restart
+
+sudo unlink /etc/apache2/sites-available/000-default.conf
+CONF=/etc/apache2/sites-available/000-default.conf
+touch $CONF
+
+cat > "$CONF" <<EOF
+<VirtualHost *:80>
+        ServerAdmin webmaster@localhost
+        DocumentRoot /var/www/html
+        <Directory />
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /var/www/html>
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+#RESTART
+a2ensite 000-default.conf
+service apache2 reload
+
+BASE=/etc/apache2/sites-available/base.conf
+touch $BASE
+
+cat > "$BASE" <<EOF
+<VirtualHost $IP:80>
+        ServerAdmin webmaster@localhost
+        DocumentRoot /var/www/html
+        <Directory />
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /var/www/html>
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+#RESTART
+a2ensite base.conf
+service apache2 reload
+
+#LET'S ENCRYPT
+sudo add-apt-repository -y ppa:certbot/certbot
+sudo apt-get update
+sudo apt-get -y install python-certbot-apache
+sudo service apache2 restart
+
+#COMPOSER INSTALLATION
+sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+sudo php composer-setup.php
+sudo php -r "unlink('composer-setup.php');"
+sudo mv composer.phar /usr/local/bin/composer
+
+#SSH AND ROOT ACCESS CONFIGURATION
+PORT=$(( ((RANDOM<<15)|RANDOM) % 63001 + 2000 ))
+sudo rpl -i -w "# Port 22" "Port 22" /etc/ssh/sshd_config
+sudo rpl -i -w "#Port 22" "Port 22" /etc/ssh/sshd_config
+sudo rpl -i -w "Port 22" "Port $PORT" /etc/ssh/sshd_config
+sudo rpl -i -w "PermitRootLogin yes" "PermitRootLogin no" /etc/ssh/sshd_config
+sudo service sshd restart
+echo -e "\n"
+
+#FINAL MESSAGGE
+clear
+echo "###################################################################################"
+echo "                              INSTALLATION COMPLETE "
+echo "###################################################################################"
+echo ""
+echo "IP: $IP"
+echo "SSH port: $PORT"
+echo "Root User / Pass: $USER / $PASS"
+echo "MySql root password: $DBPASS"
+echo "Installed phpmyadmin URL: http://$IP/phpmyadmin/"
+echo ""
+echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+echo ""
+echo "###################################################################################"
+echo ""

+ 194 - 0
go-18.sh

@@ -0,0 +1,194 @@
+#!/bin/bash
+
+#START
+echo "###################################################################################"
+echo "Please be Patient: Installation will start now....... It may take some time :)"
+echo "###################################################################################"
+echo -e "\n"
+
+#VARS
+IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
+USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
+PASS=$(openssl rand -base64 32)
+DBPASS=$(openssl rand -base64 32)
+
+#CIPI CORE
+mkdir /cipi/
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/host-add.sh -O /cipi/host-add.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/host-del.sh -O /cipi/host-del.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/ssl.sh -O /cipi/ssl.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/passwd.sh -O /cipi/passwd.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/alias-add.sh -O /cipi/alias-add.sh
+wget https://raw.githubusercontent.com/andreapollastri/cipi/master/alias-del.sh -O /cipi/alias-del.sh
+DBRFILE=/cipi/DBR
+touch $DBRFILE
+cat > "$DBRFILE" <<EOF
+$DBPASS
+EOF
+sudo chmod o-r /cipi
+
+#ALIAS
+shopt -s expand_aliases
+alias ll='ls -alF'
+
+#NEWROOT USER
+sudo useradd -m -s /bin/bash $USER
+echo "$USER:$PASS"|chpasswd
+usermod -aG sudo $USER
+
+#PHP7 PPA
+sudo apt-get -y install python-software-properties
+sudo add-apt-repository -y ppa:ondrej/php
+
+#REPO UPDATES
+sudo apt-get update
+
+#LAMP INSTALLATION
+sudo apt-get -y install rpl fail2ban openssl apache2 php7.2 php7.2-common php7.2-cli php7.2-fpm php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php-gettext php7.2-zip php7.2-mysql php7.2-xml libmcrypt-dev mysql-client
+
+#FIREWALL
+sudo ufw --force-enable reset
+
+#MYSQL INSTALLATION AND PASSWORD SET
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASS"
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASS"
+sudo apt-get -y install mysql-server
+
+#SERVICE RESTART AND CONFIGURATION FIXING
+echo -e "\n"
+sudo a2enmod rewrite
+echo -e "\n"
+sudo a2enmod proxy_fcgi setenvif
+echo -e "\n"
+sudo a2enconf php7.2-fpm
+echo -e "\n"
+sudo rpl -i -w "AllowOverride None" "AllowOverride All" /etc/apache2/apache2.conf
+echo -e "\n"
+sudo service apache2 restart && apache2 reload && service mysql restart > /dev/null
+echo -e "\n"
+php -v
+if [ $? -ne 0 ]; then
+   echo "Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)"
+else
+   echo "Installed Services run $(tput bold)$(tput setaf 2)Sucessfully$(tput sgr0)"
+fi
+
+#PHPMYADMIN INSTALLATION
+set -euo pipefail
+IFS=$'\n\t'
+sudo add-apt-repository --remove ppa:nijel/phpmyadmin
+sudo apt-get update
+sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install phpmyadmin
+sudo service apache2 restart
+sudo apt-get clean
+sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
+sudo a2enconf phpmyadmin.conf
+sudo service apache2 reload
+
+#DEFAULT VIRTUALHOST
+sudo rm -rf /var/www/html/
+sudo mkdir /var/www/html/
+BASE=/var/www/html/index.html
+touch $BASE
+cat > "$BASE" <<EOF
+<title>It works!</title><br><br>
+<center><h1>It works!</h1></center>
+EOF
+sudo service apache2 restart
+
+sudo unlink /etc/apache2/sites-available/000-default.conf
+CONF=/etc/apache2/sites-available/000-default.conf
+touch $CONF
+
+cat > "$CONF" <<EOF
+<VirtualHost *:80>
+        ServerAdmin webmaster@localhost
+        DocumentRoot /var/www/html
+        <Directory />
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /var/www/html>
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+#RESTART
+a2ensite 000-default.conf
+service apache2 reload
+
+BASE=/etc/apache2/sites-available/base.conf
+touch $BASE
+
+cat > "$BASE" <<EOF
+<VirtualHost $IP:80>
+        ServerAdmin webmaster@localhost
+        DocumentRoot /var/www/html
+        <Directory />
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /var/www/html>
+          Order allow,deny
+          Options FollowSymLinks
+          Allow from all
+          AllowOverRide All
+          Require all granted
+          SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+#RESTART
+a2ensite base.conf
+service apache2 reload
+
+#LET'S ENCRYPT
+sudo add-apt-repository -y ppa:certbot/certbot
+sudo apt-get update
+sudo apt-get -y install python-certbot-apache
+sudo service apache2 restart
+
+#COMPOSER INSTALLATION
+sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+sudo php composer-setup.php
+sudo php -r "unlink('composer-setup.php');"
+sudo mv composer.phar /usr/local/bin/composer
+
+#SSH AND ROOT ACCESS CONFIGURATION
+PORT=$(( ((RANDOM<<15)|RANDOM) % 63001 + 2000 ))
+sudo rpl -i -w "# Port 22" "Port 22" /etc/ssh/sshd_config
+sudo rpl -i -w "#Port 22" "Port 22" /etc/ssh/sshd_config
+sudo rpl -i -w "Port 22" "Port $PORT" /etc/ssh/sshd_config
+sudo rpl -i -w "PermitRootLogin yes" "PermitRootLogin no" /etc/ssh/sshd_config
+sudo service sshd restart
+echo -e "\n"
+
+#FINAL MESSAGGE
+clear
+echo "###################################################################################"
+echo "                              INSTALLATION COMPLETE "
+echo "###################################################################################"
+echo ""
+echo "IP: $IP"
+echo "SSH port: $PORT"
+echo "Root User / Pass: $USER / $PASS"
+echo "MySql root password: $DBPASS"
+echo "Installed phpmyadmin URL: http://$IP/phpmyadmin/"
+echo ""
+echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+echo ""
+echo "###################################################################################"
+echo ""

+ 131 - 0
host-add.sh

@@ -0,0 +1,131 @@
+#!/usr/bin/env bash
+
+USER_NAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
+PASSWORD=$(openssl rand -base64 24)
+DOMAIN=
+DBROOT=$(for word in $(cat /cipi/DBR); do echo $word; done)
+IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
+DBNAME=$USER_NAME
+DBUSER=$USER_NAME
+DBPASS=$(openssl rand -base64 16)
+
+USER_SHELL=/bin/bash
+
+# Check if user is root
+if [ $(id -u) != "0" ]; then
+    echo "Error: You must be root to run this script."
+    exit 1
+fi
+
+while [ -n "$1" ] ; do
+            case $1 in
+            -d | --domain )
+                    shift
+                    DOMAIN=$1
+                    ;;                                                                
+            * )
+                    echo "ERROR: Unknown option: $1"
+                    exit -1
+                    ;;
+            esac
+            shift
+done
+
+#CREATE USER
+isUserExits(){
+    grep $1 /etc/passwd > /dev/null
+    [ $? -eq 0 ] && return $TRUE || return $FALSE
+}
+
+if ( ! isUserExits $USER_NAME )
+    then 
+        sudo useradd -m -s $USER_SHELL -d /home/$USER_NAME -G www-data $USER_NAME 
+        echo "$USER_NAME:$PASSWORD"|chpasswd
+	sudo chmod o-r /home/$USER_NAME
+    else
+        echo "Error: Retry to run this script!"
+        exit 1
+fi
+
+mkdir /home/$USER_NAME/web
+chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
+
+CONF=/etc/apache2/sites-available/$USER_NAME.conf
+touch $CONF
+
+cat > "$CONF" <<EOF
+<VirtualHost $DOMAIN:80>
+	ServerName $DOMAIN
+        ServerAlias www.$DOMAIN
+        ServerAdmin webmaster@localhost
+        DocumentRoot /home/$USER_NAME/web
+	ErrorLog /home/$USER_NAME/error.log
+  	CustomLog /home/$USER_NAME/access.log combined
+        <Directory />
+                Order allow,deny
+				Options FollowSymLinks
+				Allow from all
+				AllowOverRide All
+				Require all granted
+                SetOutputFilter DEFLATE
+        </Directory>
+        <Directory /home/$USER_NAME/web>
+				Order allow,deny
+				Options FollowSymLinks
+				Allow from all
+				AllowOverRide All
+				Require all granted
+                SetOutputFilter DEFLATE
+        </Directory>
+</VirtualHost>
+EOF
+
+#MYSQL USER AND DB
+/usr/bin/mysql -u root -p$DBROOT <<EOF
+CREATE DATABASE IF NOT EXISTS $DBNAME;
+CREATE USER $DBUSER@'localhost' IDENTIFIED BY '$DBPASS';
+GRANT USAGE ON *.* TO '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASS' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
+GRANT ALL PRIVILEGES ON $DBNAME.* TO $DBUSER@'localhost';
+EOF
+DBRFILE=/cipi/$DBUSER
+touch $DBRFILE
+cat > "$DBRFILE" <<EOF
+$DBPASS
+EOF
+
+#RESTART
+a2ensite $USER_NAME.conf
+service apache2 reload
+
+#SSL CERTIFICATE
+certbot --apache -d $DOMAIN --non-interactive --agree-tos --email admin@admin.com
+certbot --apache -d www.$DOMAIN --non-interactive --agree-tos --email admin@admin.com
+CRON=/cipi/certbot_renew_$USER_NAME.sh
+touch $CRON
+cat > "$CRON" <<EOF
+sudo certbot certonly --noninteractive --apache --agree-tos --email admin@admin.com --d $DOMAIN,www.$DOMAIN --post-hook "service apache2 reload"
+EOF
+TASK=/etc/cron.d/certbot_renew_$USER_NAME.crontab
+touch $TASK
+cat > "$TASK" <<EOF
+0 1 * * * $USER_NAME /cipi/certbot_renew_$USER_NAME.sh
+EOF
+crontab /etc/cron.d/certbot_renew_$USER_NAME.crontab
+
+#RESUME
+clear
+echo "###################################################################################"
+echo "                              INSTALLATION COMPLETE "
+echo "###################################################################################"
+echo ""
+echo "Domain: $DOMAIN"
+echo "SFTP/SSH User / Pass: $USER_NAME / $PASSWORD"
+echo "Document Root: /home/$USER_NAME/web/"
+echo "MySQL DB Name: $DBNAME"
+echo "MySQL DB User / Pass: $DBUSER / $DBPASS"
+echo "Installed phpmyadmin URL: http://$DOMAIN/phpmyadmin/"
+echo ""
+echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+echo ""
+echo "###################################################################################"
+echo ""

+ 44 - 0
host-del.sh

@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+
+USER_NAME=
+DBROOT=$(for word in $(cat /cipi/DBR); do echo $word; done)
+
+while [ -n "$1" ] ; do
+            case $1 in
+            -u | --user* )
+                    shift
+                    USER_NAME=$1
+                    ;;
+            * )
+                    echo "ERROR: Unknown option: $1"
+                    exit -1
+                    ;;
+            esac
+            shift
+done
+
+#LINUX USER
+userdel -r $USER_NAME
+
+#MYSQL USER AND DB
+/usr/bin/mysql -u root -p$DBROOT <<EOF
+DROP DATABASE $USER_NAME;
+DROP USER '$USER_NAME'@'localhost';
+EOF
+unlink /cipi/$USER_NAME
+
+#SSL CERTIFICATE
+unlink /cipi/certbot_renew_$USER_NAME.sh
+unlink /etc/cron.d/certbot_renew_$USER_NAME.crontab
+crontab -u $USER_NAME -r
+
+#APACHE
+a2dissite $USER_NAME.conf
+
+#RESTART
+service apache2 reload
+
+echo "###################################################################################"
+echo "                               DELETE COMPLETE "
+echo "###################################################################################"
+echo ""

+ 66 - 0
passwd.sh

@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+
+USER=
+PASS=$(openssl rand -base64 32)
+DBPASS=$(openssl rand -base64 32)
+
+# Check if user is root
+if [ $(id -u) != "0" ]; then
+    echo "Error: You must be root to run this script."
+    exit 1
+fi
+
+while [ -n "$1" ] ; do
+      case $1 in
+      -u | --user )
+              shift
+              USER=$1
+              ;;                                                                
+      * )
+              echo "ERROR: Unknown option: $1"
+              exit -1
+              ;;
+      esac
+      shift
+done
+
+#CHANGE LINUX USER PASSWORD
+echo "$USER:$PASS"| sudo chpasswd
+
+#CHANGE MYSQL PASSWORD
+if [ -f "/cipi/$USER" ]
+then    
+
+    DBOLDPASS=$(for word in $(cat /cipi/$USER); do echo $word; done)
+    sudo mysqladmin -u $USER -p'$DBOLDPASS' password '$DBPASS'
+
+    #FINAL MESSAGGE
+    clear
+    echo "###################################################################################"
+    echo "                              USER PASSWORDS CHANGED "
+    echo "###################################################################################"
+    echo ""
+    echo "SFTP/SSH User / Pass: $USER / $PASS"
+    echo "MySql User / Pass: $USER / $DBPASS"
+    echo ""
+    echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+    echo ""
+    echo "###################################################################################"
+    echo ""
+
+else
+
+    #FINAL MESSAGGE
+    clear
+    echo "###################################################################################"
+    echo "                               USER PASSWORD CHANGED "
+    echo "###################################################################################"
+    echo ""
+    echo "SFTP/SSH User / Pass: $USER / $PASS"
+    echo ""
+    echo "                       >>>>> DO NOT LOSE THIS DATA! <<<<<"
+    echo ""
+    echo "###################################################################################"
+    echo ""
+
+fi

+ 27 - 0
ssl.sh

@@ -0,0 +1,27 @@
+
+#!/usr/bin/env bash
+
+DOMAIN=
+
+# Check if user is root
+if [ $(id -u) != "0" ]; then
+    echo "Error: You must be root to run this script."
+    exit 1
+fi
+
+while [ -n "$1" ] ; do
+      case $1 in
+      -d | --domain )
+              shift
+              DOMAIN=$1
+              ;;                                                                
+      * )
+              echo "ERROR: Unknown option: $1"
+              exit -1
+              ;;
+      esac
+      shift
+done
+
+#SSL CERTIFICATE
+certbot --apache -d $DOMAIN --non-interactive --agree-tos --email admin@admin.com