re-organise config structure

This commit is contained in:
Ray Elliott 2020-09-08 18:24:06 +01:00
parent d3549ec9ed
commit e3186d9cc9
22 changed files with 54 additions and 77 deletions

View File

@ -1,4 +0,0 @@
## apache configuration
#
## uncomment if using apache
apache2_version='latest'

8
config/local/database Normal file
View File

@ -0,0 +1,8 @@
export mariadb_version='latest'
#mysql_version='latest'
export db_root_pass='9483ujtej0--=0FFFdl'
export db_name='wordpress'
export db_user='wordpress'
export db_pass='wordpress'

View File

@ -1,4 +0,0 @@
## uncomment if using mariadb
mariadb_version='latest'
db_root_pass='9483ujtej0--=0FFFdl'

View File

@ -1,3 +0,0 @@
## uncomment if using mysql
#mysql_version='latest'
#db_root_pass='9483ujtej0--=0FFFdl'

View File

@ -1,5 +0,0 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

View File

@ -1,10 +1,15 @@
## litespeed configuration apache2_version='latest'
## uncomment if using litespeed
#nginx_version='latest'
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74 ## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest' #export litespeed_version='latest'
## php version ######################
# litespeed specific #
######################
## litespeed php version
#export ls_lsphp_version='73' #export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/ ## https://openlitespeed.org/kb/1-click-install/

View File

@ -1,4 +0,0 @@
## apache configuration
#
## uncomment if using apache
# apache2_version='latest'

View File

@ -1,11 +0,0 @@
# cloudways configuration
. ./config/remote/cloudways.secret
cloudways_user='cloudways@rayelliott.dev'
cloudways_url='https://wordpress-453075-1468300.cloudwaysapps.com'
cloudways_ssh='test123@wordpress-453075-1468300.cloudwaysapps.com'
cloudways_db_name='mhhusspndh'
cloudways_db_user='mhhusspndh'

8
config/remote/database Normal file
View File

@ -0,0 +1,8 @@
# export mariadb_version='latest'
# export mysql_version='latest'
# export db_root_pass='9483ujtej0--=0FFFdl'
export db_name='mhhusspndh'
export db_user='mhhusspndh'
export db_pass='w9Chzh6fR4'

View File

@ -1,4 +0,0 @@
## uncomment if using mariadb
# mariadb_version='latest'
# db_root_pass='9483ujtej0--=0FFFdl'

View File

@ -1,3 +0,0 @@
## uncomment if using mysql
#mysql_version='latest'
#db_root_pass='9483ujtej0--=0FFFdl'

View File

@ -1,5 +0,0 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

View File

@ -1,10 +1,15 @@
## litespeed configuration # apache2_version='latest'
## uncomment if using litespeed
#nginx_version='latest'
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74 ## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest' #export litespeed_version='latest'
## php version ######################
# litespeed specific #
######################
## litespeed php version
#export ls_lsphp_version='73' #export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/ ## https://openlitespeed.org/kb/1-click-install/

View File

@ -18,11 +18,6 @@ for _file in ./config/$_target/* ; do
. "$_file" . "$_file"
done done
if [ "$_target" = remote ] && [ -n "$cloudways_user" ] ; then
echo "Using Cloudways - nothing to install"
exit
fi
# source script files # source script files
if [ -n "$_target_os" ] ; then if [ -n "$_target_os" ] ; then
_script_dir="./scripts/$_target_os" _script_dir="./scripts/$_target_os"

View File

@ -24,9 +24,9 @@ if [ -n "$wp_user" ] ; then
--wordpressplus "$url" \ --wordpressplus "$url" \
--wordpresspath "$wp_path" \ --wordpresspath "$wp_path" \
--dbrootpassword "$db_root_pass" \ --dbrootpassword "$db_root_pass" \
--dbpassword "$wp_db_pass" \ --dbpassword "$db_pass" \
--dbname "$wp_db_name" \ --dbname "$db_name" \
--dbuser "$wp_db_user" \ --dbuser "$db_user" \
--wpuser "$wp_user" \ --wpuser "$wp_user" \
--wppassword "$wp_pass" \ --wppassword "$wp_pass" \
&& ufw allow 7080 && ufw allow 7080

View File

@ -16,7 +16,7 @@
db_file="$wp_path/data.sql" db_file="$wp_path/data.sql"
wp db export --dbuser=wordpress --dbpass=$wp_db_pass --add-drop-table --alow-root "$db_file" wp db export --dbuser=wordpress --dbpass=$db_pass --add-drop-table --alow-root "$db_file"
tar czf /tmp/wordpress.tar.gz "$wp_path" tar czf /tmp/wordpress.tar.gz "$wp_path"
# scp # scp
rm "$db_file" rm "$db_file"

View File

@ -24,6 +24,10 @@ ssh -T $ssh << EOSSH
$_mysql_cmd "DROP DATABASE IF EXISTS test;" $_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'" $_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
$_mysql_cmd "CREATE DATABASE $db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost' IDENTIFIED BY '$db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
mysqladmin --user=root password "$db_root_pass" mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH EOSSH

View File

@ -24,6 +24,10 @@ ssh -T $ssh << EOSSH
$_mysql_cmd "DROP DATABASE IF EXISTS test;" $_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'" $_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
$_mysql_cmd "CREATE DATABASE $db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost' IDENTIFIED BY '$db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
mysqladmin --user=root password "$db_root_pass" mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH EOSSH

View File

@ -1,7 +1,5 @@
echo "Installing WordPress .." echo "Installing WordPress .."
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH ssh -T $ssh << EOSSH
# install wp-cli first # install wp-cli first
@ -15,15 +13,6 @@ su "$user"
if wp core is-installed --quiet --path="$wp_path" ; then if wp core is-installed --quiet --path="$wp_path" ; then
echo "WordPress already installed" echo "WordPress already installed"
else else
# first create database and user
if command -v mysql ; then
$_mysql_cmd "CREATE DATABASE $wp_db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
else
echo "ERROR: mysql not found - aborting WordPress install"
exit 40
fi
wp core download \ wp core download \
--version="$wp_version" \ --version="$wp_version" \
--path="$wp_path" \ --path="$wp_path" \
@ -31,9 +20,9 @@ else
--locale="$wp_locale" --locale="$wp_locale"
wp config create \ wp config create \
--path="$wp_path" \ --path="$wp_path" \
--dbname="$wp_db_name" \ --dbname="$db_name" \
--dbuser="$wp_db_user" \ --dbuser="$db_user" \
--dbpass="$wp_db_pass" \ --dbpass="$db_pass" \
--locale="$wp_locale" \ --locale="$wp_locale" \
--extra-php <<PHP --extra-php <<PHP
define( 'WP_DEBUG', true ); define( 'WP_DEBUG', true );

View File

@ -5,9 +5,10 @@ _mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH ssh -T $ssh << EOSSH
# remove database # remove database
if command -v mysql ; then if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $wp_db_name;" $_mysql_cmd "DROP DATABASE $db_name;"
$_mysql_cmd "CREATE DATABASE $db_name;"
else else
echo "ERROR: no installed database found - aborting WordPress removal" echo "ERROR: mysql not found - aborting WordPress removal"
exit 40 exit 40
fi fi
# remove files # remove files

View File

@ -11,8 +11,8 @@ ssh -T $ssh << EOSSH
cd "$wp_path" cd "$wp_path"
wp db export \ wp db export \
--path="$wp_path" \ --path="$wp_path" \
--dbuser="$wp_db_user" \ --dbuser="$db_user" \
--dbpass="$wp_db_pass" \ --dbpass="$db_pass" \
--add-drop-table \ --add-drop-table \
--allow-root \ --allow-root \
"/tmp/$_db_filename" "/tmp/$_db_filename"

View File

@ -5,7 +5,8 @@ _mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH ssh -T $ssh << EOSSH
# remove database # remove database
if command -v mysql ; then if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $wp_db_name;" $_mysql_cmd "DROP DATABASE $db_name;"
$_mysql_cmd "CREATE DATABASE $db_name;"
else else
echo "ERROR: no installed database found - aborting WordPress removal" echo "ERROR: no installed database found - aborting WordPress removal"
exit 40 exit 40