Last active
May 7, 2019 20:01
-
-
Save NorthDecoder/04f5b2215c3b3614d82027c9bfd7d7e3 to your computer and use it in GitHub Desktop.
Install CMS Concrete 5 from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# filename: install_concrete5.sh | |
# License: https://mit-license.org/ | |
# For installing CMS [concrete5](https://www.concrete5.org/) from | |
# the command line. | |
# Usage: | |
# ------ | |
# 1. Locate this script in a directory ~/ic5 | |
# next to directory ~/public_html , but not in web directory. | |
# | |
# 2. Locate script ` secretCredentials.sh ` in directory ~/ic5 | |
# | |
# 3. Change to executable ` $ chmod 700 install-concrete5-latest.sh ` | |
# | |
# 4. Edit the database credentials in file secretCredentials.sh | |
# | |
# 5. Run the script with ` $ ./install-concrete5-latest.sh ` | |
# If you want to determine how long the script takes to run | |
# try `$ time ./install-concrete5-latest.sh` | |
# | |
# run this with stdout and sterr piped to a logfile: | |
# $ ./install-concrete5-latest.sh 2>&1 | tee -a command.log | |
# | |
# Inspect the installation results by opening the command.log | |
# with an editor. | |
# | |
# 6. You can also ssh into the server with another terminal | |
# and run the command `$ top ` to confirm which processes | |
# are running. | |
# | |
# 7. To install cleanly the database must have no tables | |
# and the installation directory to be non-existant. Ie | |
# this script will not empty the database, nor delete an | |
# existing install directory. You must manage separately. | |
clear | |
scriptName=$(basename "$0") | |
bluebackground="\e[30;48;5;19m"; # format for echo command | |
defaultcolors="\e[0m"; # return format to default term colors | |
ct="${bluebackground} ic5 ${defaultcolors}" #color tag comments | |
echo -e "\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" "Running script "$scriptName | |
echo " " | |
secrets="secretCredentials.sh" | |
# MySQL datasource connection from credentials provided to Database Wizard | |
echo -e "$ct" "Acquiring credentials from the file \n"\ | |
" "$secrets | |
echo " " | |
# require this file | |
. ./$secrets | |
echo -e "$ct" "Prepare to install in the web root directory" | |
echo -e "$ct" "by changing to directory ~/public_html" | |
echo " " | |
cd ~/public_html | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# Build an installation directory name | |
echo -e "\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Retrieve version list from Packagist \n" | |
# request that composer return a csv list of versions like: | |
# versions : dev-master, 8.4.2, 8.4.1, 8.4.0,... | |
versionList=$(composer show -a concrete5/concrete5 | grep versions) | |
#remove all the `dev-*` versions | |
versionList=$( echo $versionList | sed 's/dev-[^ ]*//g' ) | |
# Assuming composer always returns latest version number | |
# as first item in list!! (excluding dev- items) | |
# remove `versions:` at first column | |
# then remove everthing but first revision number delimited by `,` | |
# then remove the dots from the version number | |
# then remove whitespace before the version number | |
vn=$( echo $versionList | \ | |
cut -d \: -f 2 | \ | |
cut -d \, -f 1 ) | |
echo " " | |
echo -e "$ct" \ | |
"Latest concrete5 version: "$vn; | |
latestC5version=$( echo $vn | \ | |
tr -d "." | \ | |
tr -d " " ) | |
# where to install concrete5 | |
INSTALL_DIRECTORY_PROJECT_NAME="c5_"$latestC5version | |
# End build an installation directory name | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
echo -e "\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Preparing to download concrete5 into \n" \ | |
" a new project "$INSTALL_DIRECTORY_PROJECT_NAME " with composer:" | |
echo " " | |
# if the project does not exist then create it | |
if [ ! -d "$INSTALL_DIRECTORY_PROJECT_NAME" ]; then | |
# https://github.com/concrete5/composer | |
composer create-project -n concrete5/composer $INSTALL_DIRECTORY_PROJECT_NAME | |
cd $INSTALL_DIRECTORY_PROJECT_NAME | |
else | |
# do not recreate the project | |
echo -e "$ct" \ | |
"Did NOT download concrete5" | |
echo -e "$ct" \ | |
"Project "$INSTALL_DIRECTORY_PROJECT_NAME" already exists. \n" \ | |
" Using the existing project." | |
cd $INSTALL_DIRECTORY_PROJECT_NAME | |
fi | |
echo -e "\n\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Install concrete5 into the database: \n" \ | |
" Please do not cancel me. This may take 20 to 40 minutes. \n" \ | |
" Keep your terminal connection to the server alive... " | |
echo " " | |
if [[ $STARTING_POINT=="elemental_full" ]]; then | |
echo -e "$ct" \ | |
"Installing elemental_full \n" | |
fi | |
#https://documentation.concrete5.org/developers/appendix/cli-commands | |
cd public | |
./concrete/bin/concrete5 c5:install \ | |
--db-server="$DB_SERVER" --db-username="$DB_USERNAME" \ | |
--db-password="$DB_PASSWORD" --db-database="$DB_NAME" \ | |
--site="$SITE_NAME" --starting-point="$STARTING_POINT" \ | |
--admin-email="$EMAIL" --admin-password="$PASSWORD" \ | |
--site-locale="$LOCALE" | |
echo -e "\n\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Git cloning theme: supermint into directory" | |
cd ~/public_html/$INSTALL_DIRECTORY_PROJECT_NAME/public/packages | |
printf " "$( pwd )"\n" | |
echo " " | |
git clone https://github.com/VividVenturesLLC/theme_supermint.git | |
# Reference: | |
# https://documentation.concrete5.org/developers/installation/installation | |
# step 4. | |
echo -e "\n\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Change all project files permisions to rwx r-x r-x" | |
echo " " | |
cd ~/public_html | |
chmod -R 755 $INSTALL_DIRECTORY_PROJECT_NAME/* | |
echo -e "\n\n\n" | |
echo "* * * * * * * * * * * * * * * * * * * * * * " | |
echo -e "$ct" \ | |
"Continue the setup in a web browser, go to URL: " | |
echo " "$HOSTNAME"/"$INSTALL_DIRECTORY_PROJECT_NAME"/public/index.php" | |
echo " " | |
echo " Aba, Aba, daba that all folks!" | |
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! | |
# WARNING: Do not store your secrets in | |
# configuration management or | |
# version control as they may | |
# become publicly available | |
# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! | |
# this file is required by the install_concrete5.sh file | |
# Edit these to match the secrets for your server | |
# Reference | |
# https://documentation.concrete5.org/developers/appendix/cli-commands | |
# MySQL datasource connection from credentials provided to | |
# the cPanel Database Wizard or other setup commands. | |
DB_SERVER="localhost" | |
DB_USERNAME="assignedname_customname" | |
DB_PASSWORD="a-long-random-password" | |
DB_NAME="assignedname_anothercustomname" | |
SITE_NAME="Name Used by the C5 Site" | |
# choose one starting point but not both | |
# STARTING_POINT="elemental_full" # OR "elemental_blank" | |
STARTING_POINT="elemental_blank" # OR "elemental_full" | |
EMAIL="webmaster@mybiznamehere.com" | |
PASSWORD="administration-password-for-concrete5-cms" | |
LOCALE="en_US" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment