Larvela
Larvela

Script to create a DB and update the .env file

Overview

This script creates a DataBase name of your choosing but ranomizes the user and password fields and creates or update the .env file.

Hosting Directory

#!/bin/bash
#
# 2018-08-06
# Sid Young
# Create DB parameters for a Larvela instance and a .env file with the details
# if the file is present, add it to the bottom of the .env file commented out
#
#
DBNAME=temp
DBUSER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
DBPWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
read -p "Enter New DB name: " DBNAME

CREATE_DB_SQL="create database ${DBNAME};"
CREATE_DB_USER_SQL="create user '${DBUSER}'@'localhost' identified by '${DBPWD}';"
CREATE_DB_PERMS_SQL="grant all privileges on ${DBNAME}.* to '${DBUSER}'@'localhost';"


echo "========================================================== "
echo " "
echo "  DB Create parameters are:"
echo " "
echo ${CREATE_DB_SQL} | mysql mysql
echo ${CREATE_DB_USER_SQL} | mysql mysql
echo ${CREATE_DB_PERMS_SQL} | mysql mysql
echo " "
echo "Updating  .env file "

if [ ! -f .env ]; then
    echo "File not found!"
	echo "DB_CONNECTION=mysql" >> .env
	echo "DB_HOST=127.0.0.1" >> .env
	echo "DB_PORT=3306" >> .env
	echo "DB_DATABASE=${DBNAME}" >> .env
	echo "DB_USERNAME=${DBUSER}" >> .env
	echo "DB_PASSWORD=${DBPWD}" >> .env
	echo "# " >> .env
	echo "# " >> .env
	echo "CACHE_DRIVER=file" >> .env
	echo "SESSION_DRIVER=file" >> .env
	echo "QUEUE_DRIVER=sync" >> .env
	echo "# " >> .env
	echo "# Set CACHE,SESSION and QUEUE to redis when its installed" >> .env
	echo "# " >> .env
	echo "#REDIS_HOST=127.0.0.1" >> .env
	echo "#REDIS_PASSWORD=null" >> .env
	echo "#REDIS_PORT=6379" >> .env
	echo "# " >> .env
	echo "# " >> .env
	echo "MAIL_DRIVER=smtp" >> .env
	echo "MAIL_HOST=localhost" >> .env
	echo "MAIL_PORT=25" >> .env
	echo "MAIL_USERNAME=null" >> .env
	echo "MAIL_PASSWORD=null" >> .env
	echo "MAIL_ENCRYPTION=null" >> .env
else
	echo "# " >> .env
	echo "# " >> .env
	echo "#DB_DATABASE=${DBNAME}" >> .env
	echo "#DB_USERNAME=${DBUSER}" >> .env
	echo "#DB_PASSWORD=${DBPWD}" >> .env
	echo "# " >> .env
	echo "# end of .env file " >> .env
fi
echo "Done!"



About Larvela

Larvela is a Laravel 5 web application providing a fast and simple eCommerce framework and natively supports the Bootstrap Responsive UI framework. It was developed to replace aging Magento stores that had become to complicated and expensive to upgrade or maintain.

Larvela provides a host of feature you find in high end enterprise stores while still providing all the basic functions needed to enable your customers to view products and make purchases.

Larvela is currently in Beta release and is being used in production systems daily.

CONTACT INFO



Mobile:
Hours: ( )
E-Mail: gro.alevral@ofni

MAILING LIST