Compare commits

..

No commits in common. "f858776a9e0f32b5d68f40be55d34062c09eec53" and "c6efac505ccb825dbbbf7a0917cc7e1bb4bddba9" have entirely different histories.

24 changed files with 86 additions and 241 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
files/private files/private
*.secret

View File

@ -7,4 +7,6 @@ Development environment base packages:
## TODO ## TODO
* make sure to use export in all config files (the newer ones aren't) * combine install-local.sh and install-remote.sh into one script that takes
an argument of local/remote
* get remote working with cloudways

View File

@ -1,4 +1,4 @@
## apache configuration ## apache configuration
#
## uncomment if using apache ## uncomment if using apache
# apache2_version='latest' #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'

View File

@ -9,5 +9,5 @@
## https://openlitespeed.org/kb/1-click-install/ ## https://openlitespeed.org/kb/1-click-install/
## password used to log into litespeed web interface ## password used to log into litespeed web interface
#export ls_webadmin_pass='admin' #export ls_webadmin_pass='x7__+85676--Dd'

View File

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

View File

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

View File

@ -1,5 +1,5 @@
## php configuration ## php configuration
# #
## uncomment if using php ## uncomment if using php
# php_version='latest' #php_version='latest'

View File

@ -1,5 +1,5 @@
## ssh configuration ## ssh configuration
## uncomment if connecting via ssh ## uncomment if connecting via ssh
# export ssh='root@test123.isnet.uk' #export ssh='root@test123.example.com'

View File

@ -1,6 +1,7 @@
## user configuration ## user configuration
## uncomment to set user ## uncomment to set user
# export user='ray' ## webuser/webgroup
# export user_pass='ray' ## leave commented for default
# export group='ray' #export webuser='www-data'
#export webgroup='www-data'

View File

@ -1,23 +1,24 @@
## wordpress configuration - uncomment if using wordpress ## wordpress configuration - uncomment if using wordpress
# export wp_user='admin' # export wp_user='admin'
# export wp_pass='admin' # export wp_pass=''
# export wp_email='myemail@isnet.uk'
# export wp_version='latest' ## leave commented if using default
# export wp_path='/var/www/html/wordpress' # export wp_path='/var/www/html/wordpress'
# export wp_locale='en_GB'
# export wp_title='The WordPress'
# export db_root_pass='9dn,s93j_UU9--s889d8dUY'
# export wp_db_name='wordpress' # export wp_db_name='wordpress'
# export wp_db_user='wordpress' # export wp_db_user='wordpress'
# export wp_db_pass='wordpress' # export wp_db_pass='__d39fhi3nkjdflk8-ddWEs'
## list of themes to install - first one will be activated ## list of themes to install - first one will be activate
# export wp_themes="twentytwenty" # export wp_themes="twentytwenty"
## list of plugins to install ## list of plugins to install
# export wp_plugins="akismet all-in-one-seo-pack" # export wp_plugins=""
## list of plugins to install and activate ## list of plugins to activate
# export wp_plugins_active="" # export wp_plugins_active=""
## list of plugins to uninstall
# export wp_plugins_uninstall="hello aksimet"

0
data/.gitkeep → export-to-remote.sh Normal file → Executable file
View File

0
data/local/.gitkeep → import-from-remote.sh Normal file → Executable file
View File

62
install-local.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/sh
# default scripts to use
_script_dir='./scripts/debian10'
if [ -n "$1" ] ; then
_script_dir="./scripts/$1"
if ! [ -d "$_script_dir" ] ; then
echo "Error: script directory not found '$_script_dir'"
exit 1
fi
fi
echo "Using Scripts in: $_script_dir"
# source our config files
for _file in ./config/local/* ; do
. "$_file"
done
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
# update local server
echo "Updating .."
ssh -T $ssh << EOSSH
export DEBIAN_FRONTEND=noninteractive
apt-get -qq -y update && apt-get -qq -y upgrade
EOSSH
echo "Update complete"
. "$_script_dir/install-user.sh"
. "$_script_dir/install-base.sh"
if [ -n "$php_version" ] ; then
. "$_script_dir/install-php.sh"
fi
if [ -n "$mariadb_version" ] ; then
. "$_script_dir/install-mariadb.sh"
elif [ -n "$mysql_version" ] ; then
. "$_script_dir/install-mysql.sh"
fi
if [ -n "$apache2_version" ] ; then
. "$_script_dir/install-apache2.sh"
elif [ -n "$nginx_version" ] ; then
# TODO nginx install script
echo 'TODO - nginx install script'
elif [ -n "$litespeed_version" ] ; then
# TODO
echo 'TODO litespeed install script'
fi
if [ -n "$wp_user" ] ; then
. "$_script_dir/install-wordpress.sh"
fi
if [ -n "$dev_env" ] ; then
. "$_script_dir/install-dev-base.sh"
fi

0
data/remote/.gitkeep → install-remote.sh Normal file → Executable file
View File

View File

@ -1,77 +0,0 @@
#!/bin/sh
_target="$1"
_target_os="$2"
# default scripts to use
_script_dir='./scripts/debian10'
if ! [ "$_target" = local ] && ! [ "$_target" = remote ] ; then
echo "Error: must specify 'local' or 'remote' target"
exit 1
fi
echo "Loading $_target configuration"
# source our config files
for _file in ./config/$_target/* ; do
[ -e "$_file" ] || continue
. "$_file"
done
if [ "$_target" = remote ] && [ -n "$cloudways_user" ] ; then
echo "Using Cloudways - nothing to install"
exit
fi
# source script files
if [ -n "$_target_os" ] ; then
_script_dir="./scripts/$_target_os"
if ! [ -d "$_script_dir" ] ; then
echo "Error: script directory not found '$_script_dir'"
exit 1
fi
fi
echo "Using Scripts in: $_script_dir"
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
# update
echo "Updating .."
ssh -T $ssh << EOSSH
export DEBIAN_FRONTEND=noninteractive
apt-get -qq -y update && apt-get -qq -y upgrade
EOSSH
echo "Update complete"
. "$_script_dir/install-user.sh"
# . "$_script_dir/install-base.sh"
#
# if [ -n "$php_version" ] ; then
# . "$_script_dir/install-php.sh"
# fi
#
# if [ -n "$mariadb_version" ] ; then
# . "$_script_dir/install-mariadb.sh"
# elif [ -n "$mysql_version" ] ; then
# . "$_script_dir/install-mysql.sh"
# fi
#
# if [ -n "$apache2_version" ] ; then
# . "$_script_dir/install-apache2.sh"
# elif [ -n "$nginx_version" ] ; then
# # TODO nginx install script
# echo 'TODO - nginx install script'
# elif [ -n "$litespeed_version" ] ; then
# # TODO
# echo 'TODO litespeed install script'
# fi
#
# if [ -n "$wp_user" ] ; then
# . "$_script_dir/install-wordpress.sh"
# fi
#
# if [ -n "$dev_env" ] ; then
# . "$_script_dir/install-dev-base.sh"
# fi

View File

@ -1,23 +0,0 @@
#!/bin/sh
_target="$1"
if ! [ "$_target" = local ] && ! [ "$_target" = remote ] ; then
echo "Error: must specify 'local' or 'remote' target"
exit 1
fi
echo "Loading $_target configuration"
# source our config files
for _file in ./config/$_target/* ; do
[ -e "$_file" ] || continue
. "$_file"
done
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
if [ -n "$wp_user" ] ; then
. ./scripts/export-wp.sh
fi

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,42 +0,0 @@
#!/bin/sh
_target="$1"
_target_os="$2"
# default scripts to use
_script_dir='./scripts/debian10'
if ! [ "$_target" = local ] && ! [ "$_target" = remote ] ; then
echo "Error: must specify 'local' or 'remote' target"
exit 1
fi
echo "Loading $_target configuration"
# source our config files
for _file in ./config/$_target/* ; do
[ -e "$_file" ] || continue
. "$_file"
done
# source script files
if [ -n "$_target_os" ] ; then
_script_dir="./scripts/$_target_os"
if ! [ -d "$_script_dir" ] ; then
echo "Error: script directory not found '$_script_dir'"
exit 1
fi
fi
echo "Using Scripts in: $_script_dir"
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
if [ -n "$wp_user" ] ; then
# TODO - confirmation prompt
echo "IMPORTANT - we need a confirmation prompt here"
echo "You are about to reinstall the $_target WordPress installation"
echo "Reinstall WordPress (y/N): "
. "./scripts/reset-wordpress.sh"
. "$_script_dir/install-wordpress.sh"
fi

View File

@ -21,7 +21,7 @@ else
$_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';" $_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;" $_mysql_cmd "FLUSH PRIVILEGES;"
else else
echo "ERROR: mysql not found - aborting WordPress install" echo "ERROR: no installed database found - aborting WordPress install"
exit 40 exit 40
fi fi
wp core download \ wp core download \

View File

@ -1,15 +0,0 @@
echo "Removing WordPress .."
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH
# remove database
if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $wp_db_name;"
else
echo "ERROR: no installed database found - aborting WordPress removal"
exit 40
fi
# remove files
rm -Rf $wp_path
EOSSH

View File

@ -1,29 +0,0 @@
#!/bin/sh
echo "Exporting from $url .."
_timestamp="$(date +%s)"
_db_filename="wordpress-$_timestamp.db"
_archive_filename="wordpress-$_timestamp.tar.gz"
_local_dest_dir="./data/$_target"
ssh -T $ssh << EOSSH
cd "$wp_path"
wp db export \
--path="$wp_path" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--add-drop-table \
--allow-root \
"/tmp/$_db_filename"
tar czf "/tmp/$_archive_filename" "$wp_path"
EOSSH
scp "$ssh:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
exit
ssh -T $ssh << EOSSH
rm "/tmp/$_db_filename"
rm "/tmp/$_archive_filename"
EOSSH

View File

@ -1,3 +0,0 @@
#!/bin/sh

View File

@ -1,15 +0,0 @@
echo "Removing WordPress .."
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH
# remove database
if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $wp_db_name;"
else
echo "ERROR: no installed database found - aborting WordPress removal"
exit 40
fi
# remove files
rm -Rf $wp_path
EOSSH