Skip to content

Commit

Permalink
Add cookie domain configuration and table_prefix configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristoffer Svanmark committed Sep 22, 2016
1 parent ef1a9ba commit bd09bd4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config/cookie.php → config/cookie-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @var bool
*/

if (strpos($_SERVER['HTTP_HOST'], "helsingborg.se") !== false) {
define('COOKIE_DOMAIN', ".helsingborg.se");
if (strpos($_SERVER['HTTP_HOST'], "(#cookie_domain#)") !== false) {
define('COOKIE_DOMAIN', ".(#cookie_domain#)");
} else {
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
}
2 changes: 1 addition & 1 deletion config/database-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
$table_prefix = '(#table_prefix#)';
51 changes: 37 additions & 14 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,81 @@
#!/bin/bash

echo "\033[35mWelcom to the Municipio boilerplate setup. Please follow the steps in this setup guide in order to set up your wp-config.\033[0m"
echo "\033[35mWelcom to the Municipio boilerplate setup.\nPlease follow the steps in this setup guide in order to set up your wp-config.\033[0m"

#
##
### DATABASE
##
#

echo "\033[34m\033[1mDatabase host:\033[0m "
echo "\n\033[34m\033[1mDatabase host:\033[0m "
read db_host

echo "\033[34m\033[1mDatabase name:\033[0m "
echo "\n\033[34m\033[1mDatabase name:\033[0m "
read db_name

echo "\033[34m\033[1mDatabase user:\033[0m "
echo "\n\033[34m\033[1mDatabase user:\033[0m "
read db_user

echo "\033[34m\033[1mDatabase password:\033[0m "
echo "\n\033[34m\033[1mDatabase password:\033[0m "
read db_password

echo "\n\033[34m\033[1mDatabase table prefix:\033[0m "
read table_prefix

# Copy/replace database-example.php to database.php
mv ./config/database-example.php ./config/database.php

# Insert given information to database.php
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#db_host#)/$db_host/g" {} >/dev/null 2>&1 \;
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#db_name#)/$db_name/g" {} >/dev/null 2>&1 \;
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#db_user#)/$db_user/g" {} >/dev/null 2>&1 \;
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#db_password#)/$db_password/g" {} >/dev/null 2>&1 \;
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s:(#db_password#):$db_password:g" {} >/dev/null 2>&1 \;
find ./config/database.php -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#table_prefix#)/$table_prefix/g" {} >/dev/null 2>&1 \;



#
##
### COOKIE DOMAIN
##
#

echo "\n\033[34m\033[1mCookie domain (usally same as website url):\033[0m "
read cookie_domain

mv ./config/cookie-example.php ./config/cookie.php
find ./config/cookie.php -type f ! -name "setup.sh" -exec sed -i '' -e "s:(#cookie_domain#):$cookie_domain:g" {} >/dev/null 2>&1 \;

#
##
### COMPOSER (uppdatera package name osv)
##
#

echo "\033[34m\033[1mComposer name (vendor/package):\033[0m "
echo "\n\033[34m\033[1mComposer name (vendor/package):\033[0m "
read composer_project

echo "\033[34m\033[1mComposer license:\033[0m "
echo "\n\033[34m\033[1mComposer license:\033[0m "
read composer_license

echo "\033[34m\033[1mComposer author name:\033[0m "
echo "\n\033[34m\033[1mComposer author name:\033[0m "
read composer_author_name

echo "\033[34m\033[1mComposer author email:\033[0m "
echo "\n\033[34m\033[1mComposer author email:\033[0m "
read composer_author_email

find ./composer.json -type f ! -name "setup.sh" -exec sed -i '' -e "s:(#composer_project#):$composer_project:g" {} >/dev/null 2>&1 \;
find ./composer.json -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#composer_license#)/$composer_license/g" {} >/dev/null 2>&1 \;
find ./composer.json -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#composer_author_name#)/$composer_author_name/g" {} >/dev/null 2>&1 \;
find ./composer.json -type f ! -name "setup.sh" -exec sed -i '' -e "s/(#composer_author_email#)/$composer_author_email/g" {} >/dev/null 2>&1 \;

echo "\033[34m\033[1mAnswer the following questions with y/n…\033[0m "





echo "\n\033[34m\033[1mAnswer the following questions with y/n…\033[0m "

#
##
Expand Down Expand Up @@ -119,7 +142,7 @@ esac
### TIME CONSUMING TASKS COMES LAST
##
#
echo "\033[34m\033[1mLean back while I set things up…\033[0m"
echo "\n\033[34m\033[1mLean back while I set things up…\033[0m"

# Run composer install
composer install
Expand All @@ -140,7 +163,7 @@ find . -maxdepth 1 -name '*.DS_Store' -delete

# All done
if [ "$multisite_prepare" == "true" ]; then
echo "\n\033[43m\033[1mNote: to complete the multisite setup you will need to run the multisite installation through wp-admin after the standard WordPress install is completed.\033[0m\n"
echo "\n\n\033[43m\033[1mNote: to complete the multisite setup you will need to run the multisite installation through wp-admin after the standard WordPress install is completed.\033[0m\n"
fi

echo "\033[92m\033[1mAll done. Please go ahead and run the WordPress install in your browser.\033[0m"
echo "\n\033[92m\033[1mAll done. Please go ahead and run the WordPress install in your browser.\033[0m"
11 changes: 10 additions & 1 deletion wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@
* @package WordPress
*/

require_once 'config/cookie.php';
require_once 'config/content.php';
require_once 'config/database.php';
require_once 'config/salts.php';
require_once 'config/plugins.php';
require_once 'config/update.php';
require_once 'config/upload.php';

/**
* Cookie settings
*
* To enable this site as a multisite please rename the config/cookie-example.php file to
* cookie.php, then go ahead and edit the configurations
*/
if (file_exists(__DIR__ . '/config/cookie.php')) {
require_once 'config/cookie.php';
}

/**
* Cache settings
*
Expand Down

0 comments on commit bd09bd4

Please sign in to comment.